SpringBoot报错:
本⽂主要跟⼤家分享了关于Spring Boot报错:No session repository could be auto-configured, check your configuration的解决⽅法,下⾯话不多说,来⼀起看看详细的介绍:
⼀、环境介绍
JDK 1.8 spring-Boot 1.5.1.RELEASE, STS IDE
⼆、问题的提出
创建了⼀个⾮常简约的Spring Boot Web Application,其中使⽤了Spring-Session,具体的maven依赖如下:
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session</artifactId>
lt;/dependency>
在启动过程中,出现了如下错误信息:
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-02-23 17:48:10.710 ERROR 29484 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.session.SessionAutoConfiguration$SessionRepositoryValidator': Invocation of init method failed; nested exception is java.lang.Ill at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:137)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1620)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(A
bstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.ateBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.Object(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.Singleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.Bean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at t.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at t.fresh(AbstractApplicationContext.java:542)
at org.t.fresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.fresh(SpringApplication.java:737)
at org.springframework.freshContext(SpringApplication.java:370)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
sebird.data.stock.StockdataApplication.main(StockdataApplication.java:10)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at flect.Method.invoke(Method.java:497)
at org.springframework.start.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.IllegalArgumentException: No session repository could be auto-configured, check your configuration (session store type is 'null')
at org.springframework.Null(Assert.java:115)
at org.springframework.boot.autoconfigure.session.SessionAutoConfiguration$SessionRepositoryValidator.checkSessionRepository(SessionAutoConfiguration.java:100)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at flect.Method.invoke(Method.java:497)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:311)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:134)
... 23 common frames omitted
异常栈很长,关键的错误信息是:No session repository could be auto-configured, check your configuration (session store type is 'null') ,这个信息对于我们进⾏问题分析提供了⾮常⼤的指引,我们将重点放在session
store type的功能分析上。
三、问题的解决与分析
session数据错误是什么意思在⽹上搜索之后,我们发现session store type使⽤来存放session的存储⽅式,⽬前Spring boot中只⽀持Redis⽅式。由于本应⽤暂⽆需将session放⼊redis的需求,故这⾥就可以将session store type设置
为none.
这⾥我们将此配置信息放⼊application.properites之中:
# default-store in spring session. it will be set in redis only outside.
spring.session.store-type=none
重新启动应⽤,错误信息消失,我们可以看到了启动正常的信息了:
2017-02-23 19:36:17.437 INFO 10500 --- [ restartedMain] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/css/**'], Ant [pattern='/js/**'], Ant [pattern='/images/**'], Ant [pattern='/webjars/**'], Ant [pa 2017-02-23 19:36:17.823 INFO 10500 --- [ restartedMain] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/**']]], [org.springframework.t.request.async.WebA
syncManagerIntegra 2017-02-23 19:36:18.163 INFO 10500 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2017-02-23 19:36:18.346 INFO 10500 --- [ restartedMain] o.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-02-23 19:36:18.570 INFO 10500 --- [ restartedMain] TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-02-23 19:36:18.588 INFO 10500 --- [ restartedMain] o.r.data.stock.StockdataApplication : Started StockdataApplication in 25.393 seconds (JVM running for 27.444)
总结
以上就是这篇⽂章的全部内容了,希望本⽂的内容对⼤家的学习或者⼯作能带来⼀定的帮助,如果有疑问⼤家可以留⾔交流,谢谢⼤家对的⽀持。
参考资料:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论