오늘, 프레임 워크 통합 중에 발생한 문제를 기록해 봅시다.
1. Redis를 사용하여 세션 공유를 구현할 때 프로젝트 시작 보고서 'SpringsessionRepositoryFilter'라는 이름의 Bean No Bean은 예외가 정의됩니다.
2. 캐시 도구 클래스를 호출 할 때 주입 된 제드 풀은 NULL입니다 (스프링 스캔과 관련된 상세 오류)
좋아, 통합 된 파일을 추가하기 시작했다
pom.xml은 JAR 패키지에 따라 다릅니다
<!-스프링 세션 시작-> <pectionency> <groupId> redis.clients </groupId> <artifactid> jedis </artifactid> <버전> 2.9.0 </version> </efcevency> <prectionement> <groupId> org.springframework.session </groupid> <artifactId> spring-session-data-redis </artifactid> 1.2.1. </의존성>
web.xml 구성
<? xml version = "1.0"encoding = "utf-8"?> <web-app xmlns : xsi = "http://www.w3.org/2001/xmlschema-instance"xmlns = "http://java.sun.com/xml/ns/javaee" xsi : schemalocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_3_0.xsd"3.0 ">"> <Param-Name> ContextConfigLocation </param-name> <param- value> classpath : spring-cfg.xml </param- value> </context-param> <!-필터 헤드에 배치 된 세션 필터-> <filter> <filter-name> springsessionRepositoryFilter </filter-name> <filter-class> org.springframework.web.filter.delegatingfilterproxy </filter-class> </filter> <filter-mapping> <filter-name> springsessionrepositoryFilter </filter-name> <Url-pattern>/*</url-pattern> </filter-mapping> <!-encoding filter. <filter-name> encodingFilter </filter-name> <filter-class> org.springframework.web.filter.characterencododingfilter </filter-class> <async-supported> true </async-supported> <init-param> <param-name> encoding </param-name> </init-param> </filter> <filter-mapping> <filter-name> encodingfilter </filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-스프링 리스너-> <layer> <layer-class> org.springframework.web.context.conxtlistener </whister> <!-Spring MVC-> <Servlet> <Servlet-name> SpringMvc </servlet-name> <servlet-class> org.springframework.web.servlet.dispatcherservlet </servlet-class> <init-param> <param-name> contextConfigLocation </param-value> classpath : spring-mvc </init-param> <load-on-startup> 1 </load-on-startup> <Async-supported> true </async-supported> </servlet> <servlet-mapping> <servlet-mapping> <servlet-name> springmvc </servlet-name> <url-pattern>/</url-pattern> <servlet-name> default </servlet-name> <url-pattern>/static/*</url-pattern> </servlet-mapping>-> </web-app>
spring-cfg.xml 구성 파일
<? xml 버전 = "1.0"alcoding = "utf-8"?> <beans xmlns = "http://www.springframework.org/schema/beans"xmlns : xsi = "http://ww.w.w3.org/2001/xmlschema-instance" xmlns : context = "http://www.springframework.org/schema/context"xmlns : aop = "http://www.springframework.org/schema/aop"xmlns : tx = "http://www.spramwork.org/schema/schema/schema/schema. xmlns : util = "http://www.springframework.org/schema/util"xsi : schemalocation = "http://www.springframework.org/schema/beans http://ww.springframework.org/schema/spred-beans- http://www.springframework.org/schema/context http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://wwww.spramegme http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/util http://www.spramework.org/schema/util/sprring-util.xsd "! 프로그래밍-> <aop : sagne-autopproxy proxy-target class = "true"/> <!-주석을 스캔하여 bean을 생성합니다-> <context : context : context : com.zyt "> <context : exclude-filter ="annotation "-"org.spramframframwork. </context : component-scan> <!-여러 속성 구성 파일 읽기-> <bean id = "propertyconfigurer"> <property name = "location"> <list> <value> classpath : jdbc.properties> <value> classpath : redis.properties> </list> </bean> <!-jod id =. <property name = "maxidle"value = "$ {redis.maxidle}"/> <속성 이름 = "maxtotal"value = "$ {redis.maxActive}"/> <property name = "maxwaitmillis"value = "$ {redis.maxwait}"/> <!-Redis의 Connection Pool은 필요한 옵션이 아닙니다. 타임 아웃/비밀번호-> <bean id = "jedispool"> <constructor-arg index = "0"ref = "poolconfig"/> <constructor-arg index = "1"value = "$ {redis.host}"/> index = "value ="$ {redis.porp.porp.port}. <Constructor-Arg index = "3"value = "$ {redis.timeout}"type = "int"/> <!-<생성자-arg index = "4"value = "$ {redis.password}"/> </bean> <!-Jedis Connection factory-> <bean id = "jedisconnection"> <PropertOfig ""rep = "rep ="rep = "rep gonfig"rep = "jedisconnection"입니다. 이름 = "port"value = "$ {redis.port}"/> <속성 이름 = "hostname"value = "$ {redis.host}"/> <!-<property name = "password"value = "$ {redis.pass}"/>-> </bean> <util : constant static-field = "org.springframework.session.data.redis.redis.config.configurerediscation.no_op"/> <!-스프링 redis 템플릿-> <bean id = "redistemplate"> <속성 이름 = "connectionfactory"ref = "jedisconnection factory"/> <!-redis end-- <spring session reget-> <reg end->. id = "redishttpsessionconfiguration"> <property name = "maxinactiveintervalinseconds"value = "1800"/> </bean> <!-mybatis의 통합-> <bean id = "sqlsessionfactory"> <property name = "dataSource"ref = "dataSource"/> <속성 이름 = "mapperlocations" value = "classpath : com/zyt/**/**. xml"/> </bean> <ean> <property name = "basepackage"value = "com.zyt.*. dao"/> <property name = "sqlsessionfactorybeanname"value = "sqlsessionfactorybeanname"value = "enotation-<tx : annotation-discation-> Transaction-Manager = "TransactionManager"/> <bean id = "transactionManager"> <property name = "dataSource"ref = "dataSource"/> </bean> <!-데이터베이스 설정-> <bean id = "dataSource"destrove-method = "close"init-method = "init"<속성 이름 = "url" 이름 = "username"value = "$ {jdbc_username}"/> <property name = "production name ="password "value ="$ {jdbc_password} "/> <!-초기화 연결 크기-> <속성 크기"value = "0"/> <! <value ""0 "/> <value"0 "/> <value" "0"/> <value ""0 "/> <! value = "property name ="minidle "value ="0 " /> <!-최대 연결 대기 시간을 가져옵니다-> <속성"value = "maxwait"value = "60000" /> <!-<property name = "pluckpreparedStatements"value = "true"value = "maxPoolPreperedStatementPerConnection" "33" />-"33". value = "$ {valicationQuery}"/> <속성 이름 = "testonborrow"value = "false"/<property name = "testonborring"value = "false"/> <property name = "test shipileidle"value = "true"/<!-Milliseconds에서 닫아야 할 유휴 결합을 감지하는 데 얼마나 오래 걸리는가-> <속성. 이름 = "TimeBetweenevictionRunsmillis"value = "60000"/> <!-밀리 초에서 수영장에서 생존하기위한 최소 시간을 구성합니다-> <속성 이름 = "MineVictableDletimemillis"value = "25200000"/> <!-retobea value = ""removeabend "/<value" "25200000"/<! 순간, 30 분-> <속성 이름 = "removeAbandonEdTimeout"value = "1800"/> <!-포기 된 연결을 닫을 때 출력 오류 로그-> <속성 이름 = "logabanded"value = "true"/<!-모니터링 데이터베이스-> <속성 이름 = "filters"value "/>-> value ="mermestat ">jdbc.properties
DriverClassName = com.mysql.jdbc.driver validationQuery = 1 JDBC_URL = JDBC : MYSQL : // localHost : 3306/zyt_demo? useUnicode = true & charac
redis.properties
redis.isopen = on redis.host = 127.0.0.1 redis.port = 6379 redis.maxidle = 300 redis.maxactive = 600 redis.maxwait = 1000 redis.testonbronge = true redis.timeout = 2000 #redis.password =
위의 것은 통합 구성 파일로, Redis에 대한 구성이 통합 성공의 핵심입니다.
질문 요약
1. 구성 파일의 위치로 인해 통합을 통합 한 후 시작 프로젝트는 예외로보고되었으므로 시작은 실패했습니다. 여러 번 시도하십시오. 위의 구성 파일을 사용할 수 있습니다.
2. 나는 이전에 캐시 도구 클래스에 전화를 걸어 Jedispool의 주입이 비어 있음을 보여 주었다. 컨트롤러에 주입되어 값이있었습니다. 컨트롤러에서 도구 클래스를 불렀던 방식은 새롭기 때문에 스프링은 도구 클래스를 스캔 할 때 제다이 풀 주입을 잃었습니다. 컨트롤러에서 주입 공구 클래스를 사용하여 해결할 수 있습니다.
예를 들어:
요약
위의 것은 Spring의 세션 공유를 실현하기 위해 Spring을 통합하는 과정입니다. 모든 사람에게 도움이되기를 바랍니다. 궁금한 점이 있으면 메시지를 남겨 주시면 편집자가 제 시간에 모든 사람에게 답장을 드리겠습니다. Wulin.com 웹 사이트를 지원해 주셔서 대단히 감사합니다!