วันนี้มาบันทึกปัญหาที่ฉันพบในระหว่างการรวมกรอบ:
1. เมื่อใช้ REDIS เพื่อใช้การแชร์เซสชันรายงานเริ่มต้นโครงการไม่มีถั่วชื่อ 'SpringsessionRepositoryFilter'
2. เมื่อโทรไปที่คลาสเครื่องมือแคชการฉีด Jedispool จะเป็นโมฆะ (ข้อผิดพลาดโดยละเอียดที่เกี่ยวข้องกับการสแกนสปริง)
โอเคฉันเริ่มเพิ่มไฟล์ที่ฉันรวมเข้าด้วยกัน
pom.xml ขึ้นอยู่กับแพ็คเกจ JAR
<!-เริ่มต้นเซสชันฤดูใบไม้ผลิ-> <การพึ่งพา> <roupId> Redis.Clients </groupId> <ratifactid> Jedis </ArtifactId> <Sersion> 2.9.0 </Side> </การพึ่งพา> <การพึ่งพา <Sersion> 1.2.1.Release </เวอร์ชัน> </predency>
การกำหนดค่า web.xml
<? xml version = "1.0" การเข้ารหัส = "utf-8"?> <web-app xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance" xmlns = "http://java.sun.com/xml 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_0.p_0.p_0.sun <param-name> contextconfiglocation </param-name> <param-value> classpath: spring-cfg.xml </param-value> </context-param> <!-ตัวกรองเซสชันที่วางไว้ในหัวตัวกรอง-> <filter> <filter-name> <Tilter-class> org.springframework.web.filter.delegatingFilterProxy </filter-class> </filter> <filter-mapping> <filter-name> SpringsessionRepositoryFilter </filter-Name> <sider-name> encodingFilter </filter-name> <filter-class> org.springframework.web.filter.characterencodingFilter </filter-class> <sync-upported> true </async-supported> </init-param> </filter> <filter-mapping> <s Filter-Name> EncodingFilter </filter-name> <url-pattern>/*</url-pattern> </spring-mapping> <!-สปริงฟัง-> <sisterer> <!-สปริง MVC-> <servlet> <servlet-name> springmvc </servlet-name> <servlet-class> org.springframework.web.servlet.dispatcherservlet </servlet-class> <int-param> </init-param> <load-on-startup> 1 </load-on-startup> <sync-upported> True </async-supported> </servlet> <servlet-mapping> <servlet-mapping> <servlet-name> ค่าเริ่มต้น </servlet-name> <url-pattern>/static/*</url-pattern> </servlet-mapping>-> </eb-app>
ไฟล์การกำหนดค่า Spring-cfg.xml
<? xml version = "1.0" การเข้ารหัส = "utf-8"?> <beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://ww.w3.org/2001/xml xmlns: context = "http://www.springframework.org/schema/context" xmlns: aop = "http://www.springframework.org/schema/aop" xmlns: tx = "http:/ xmlns: util = "http://www.springframework.org/schema/util" xsi: schemalocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://ww.springframework.org/schema/tx http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd "> <! <!-สแกนคำอธิบายประกอบเพื่อสร้างถั่ว-> <บริบท: คำอธิบายประกอบ-config/> <บริบท: ส่วนประกอบ-สแกนฐานแพคเกจ = "com.zyt"> <บริบท: ยกเว้นประเภทตัวกรอง = "คำอธิบายประกอบ" นิพจน์ = "org.springframework.steretype.controller"/> id = "PropertyConfigurer"> <property name = "locations"> <list> <value> classpath: jdbc.properties </value> <value> classpath: redis.properties </value> </list> </property> value = "$ {redis.maxidle}"/> <property name = "maxtotal" value = "$ {redis.maxactive}"/> <property name = "maxwaitmillis" value = "$ {redis.maxwait}"/> <property name = "testonborrow" พูลไม่ใช่ตัวเลือกที่จำเป็น: หมดเวลา/รหัสผ่าน-> <ถั่ว id = "jedispool"> <constructor-arg index = "0" ref = "poolconfig"/> <constructor-Arg index = "1" value = "$ {redis.host}"/> <constructor-arg index = "2" index = "3" value = "$ {redis.timeout}" type = "int"/> <!-<constructor-Arg index = "4" value = "$ {redis.password}"/> </ebean> <! value = "$ {redis.port}"/> <property name = "hostname" value = "$ {redis.host}"/> <!-<property name = "password" value = "$ {redis.pass}"/>-> </bean> Static-field = "org.springframework.session.data.edis.config.configureredisaction.no_op"/> <!-เทมเพลตสปริง redis-> <bean id = "redistemplate"> <property name = "connectionFactory" ref = "jedisconnection id = "redishttpsessionConfiguration"> <property name = "MaxinactiveIntervalinseconds" value = "1800"/> </ebean> <!-การรวม MyBatis-> <bean id = "SQLSessionFactory"> value = "classpath: com/zyt/**/**. xml"/> </ebean> <bean> <property name = "basepackage" value = "com.zyt.*. dao"/> <property name = "SQLSessionFactoryBeanName" Transaction-Manager = "TransactionManager"/> <bean id = "transactionManager"> <property name = "dataSource" ref = "dataSource"/> </ebean> <!-การตั้งค่าฐานข้อมูล-> <bean id = "dataSource" destroy-method = "close" init-method = " name = "username" value = "$ {jdbc_username}"/> <property name = "รหัสผ่าน" value = "$ {jdbc_password}"/> <! value = "property name =" minidle "value =" 0 " /> <!-รับเวลารอการเชื่อมต่อสูงสุด-> <property name =" MaxWait "value =" 60000 " /> <!-<property name =" PoolPreparedStatements "value =" true " /> value = "$ {ValidationQuery}"/> <property name = "testOnBorrow" value = "false"/> <property name = "testOnBorrow" value = "false"/> <ชื่อคุณสมบัติ = "testharileDle" value = "true"/> <! name = "timebetweenevictionrunsmillis" value = "60000"/> <!-กำหนดเวลาขั้นต่ำสำหรับการเชื่อมต่อเพื่อความอยู่รอดในสระว่ายน้ำในมิลลิวินาที-> <ชื่อทรัพย์สิน = "minevictableidletimeLis" ค่า = "25200000"/> <! นั่นคือ 30 นาที-> <property name = "removeAbandOnedTimeOut" value = "1800"/> <!-บันทึกข้อผิดพลาดเอาต์พุตเมื่อปิดการเชื่อมต่อที่ถูกทอดทิ้ง-> <property name = "logabandoned" value = "true"/> <!-ฐานข้อมูลการตรวจสอบ-> <!jdbc.properties
driverclassName = com.mysql.jdbc.driver ValidationQuery = เลือก 1 jdbc_url = jdbc: mysql: // localhost: 3306/zyt_demo? useunicode = true & caracterencoding = utf-8 & zerodatetimebehavior = Converttonull
Redis.properties
redis.isopen = บน redis.host = 127.0.0.1 redis.port = 6379 redis.maxidle = 300 redis.maxactive = 600 redis.maxwait = 1000 redis.testonborrow = True Redis.timeOut = 2000 #redis.word =
ข้างต้นคือไฟล์กำหนดค่าแบบรวมซึ่งการกำหนดค่าเกี่ยวกับ REDIS เป็นกุญแจสู่ความสำเร็จของการรวม
สรุปคำถาม
1. รายงานโครงการเริ่มต้นเป็นข้อยกเว้นหลังจากรวมการรวมเข้าด้วยกันเนื่องจากตำแหน่งของไฟล์การกำหนดค่าดังนั้นการเริ่มต้นจึงไม่สำเร็จ ลองหลายครั้ง สามารถใช้ไฟล์การกำหนดค่าด้านบน
2. ฉันเรียกคลาสเครื่องมือแคชมาก่อนและมันแสดงให้เห็นว่าการฉีดเจเดสต์นั้นว่างเปล่า ฉีดในคอนโทรลเลอร์และมีค่า เพราะวิธีที่ฉันเรียกว่าคลาสเครื่องมือบนคอนโทรลเลอร์นั้นใหม่ดังนั้นฤดูใบไม้ผลิจึงสูญเสียการฉีดเจเดสต์เมื่อสแกนคลาสเครื่องมือ สามารถแก้ไขได้โดยใช้คลาสเครื่องมือฉีดแทนในคอนโทรลเลอร์
ตัวอย่างเช่น:
สรุป
ข้างต้นเป็นกระบวนการของฤดูใบไม้ผลิที่รวม Redis (Jedis) เพื่อตระหนักถึงการแบ่งปันเซสชันฉันหวังว่ามันจะเป็นประโยชน์กับทุกคน หากคุณมีคำถามใด ๆ โปรดฝากข้อความถึงฉันและบรรณาธิการจะตอบกลับทุกคนในเวลา ขอบคุณมากสำหรับการสนับสนุนเว็บไซต์ Wulin.com!