Spring boot timeout config exception
我正在将Spring Boot 2.1.9.RELEASE与Web,会话,安全性,jdbc和jpa启动程序一起使用。
在我的应用程序中一切正常,直到我尝试覆盖默认会话超时值,并在application.properties中使用以下行:
1 | server.servlet.session.timeout=180 |
如果添加了此行,则在启动Spring时出现以下错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 2019-12-02 17:48:17.689 INFO 12824 --- [ main] o.a.c.c.C.[.[localhost].[/webapp] : Initializing Spring embedded WebApplicationContext 2019-12-02 17:48:17.689 INFO 12824 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 11388 ms 2019-12-02 17:48:17.955 WARN 12824 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionRepositoryFilterRegistration' defined in class path resource [org/springframework/boot/autoconfigure/session/SessionRepositoryFilterConfiguration.class]: Unsatisfied dependency expressed through method 'sessionRepositoryFilterRegistration' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.session-org.springframework.boot.autoconfigure.session.SessionProperties': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.session.SessionProperties]: Constructor threw exception; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'server-org.springframework.boot.autoconfigure.web.ServerProperties': Could not bind properties to 'ServerProperties' : prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'server.servlet.session.timeout' to java.time.Duration 2019-12-02 17:48:17.971 INFO 12824 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2019-12-02 17:48:17.971 ERROR 12824 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Failed to bind properties under 'server.servlet.session.timeout' to java.time.Duration: Property: server.servlet.session.timeout Value: 180 Origin:"server.servlet.session.timeout" from property source"URL [file:C:/Users/utente/eclipse-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/configurazioni/application.properties]" Reason: failed to convert java.lang.String to @org.springframework.boot.convert.DurationUnit java.time.Duration Action: Update your application's configuration |
我也尝试了不同的格式,例如180或PT180S,但没有任何效果。
根据Spring文档或同一文档的其他变体,只有整数的版本应该正确
Further customization is possible using application.properties:
src/main/resources/application.properties server.servlet.session.timeout= # Session timeout. If a duration suffix is not specified, seconds will be used.
另一个文档页面解释了其他格式,并且我知道该标准应该工作而无需声明Bean(我知道是Spring Boot本身声明了标准ConverstionService,是否正确?还是应该在@Configuration中指定某些内容?类?)。
我真的不明白我在想什么,请帮助我。
编辑:我也试图像另一个问题中所解释的那样显式地公开一个ApplicationConversionService bean,但是它不起作用,结果与以前完全相同。
好,解决了,多亏了一位同事:这只是值之后的空格(非常惊讶没有空格!)