Spring boot Spring启动超时配置异常

Spring boot Spring启动超时配置异常,spring-boot,session,properties,type-conversion,timeout,Spring Boot,Session,Properties,Type Conversion,Timeout,我正在使用SpringBootVersion2.1.9.RELEASE和web、会话、安全、jdbc和jpa启动器。 在我的应用程序中一切正常,直到我尝试用application.properties中的以下行覆盖默认会话超时值: server.servlet.session.timeout=180 如果添加了这一行,则在启动Spring时会出现以下错误: 2019-12-02 17:48:17.689 INFO 12824 --- [ main] o.a.c.c.C.[

我正在使用SpringBootVersion2.1.9.RELEASE和web、会话、安全、jdbc和jpa启动器。 在我的应用程序中一切正常,直到我尝试用application.properties中的以下行覆盖默认会话超时值:

server.servlet.session.timeout=180
如果添加了这一行,则在启动Spring时会出现以下错误:

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
我也尝试了不同的格式,比如180s或PT180S,但都不起作用。 根据同一文档的其他变体,只有整数的版本应该是正确的

可以使用application.properties进行进一步自定义:

server.servlet.session.timeout=180
src/main/resources/application.properties server.servlet.session.timeout=#session timeout。如果未指定持续时间后缀,将使用秒

page解释了其他格式,我理解标准应该可以工作,而不需要声明bean(我理解是Spring boot本身声明了标准ConversationService,是正确的吗?还是应该在@Configuration类中指定一些内容?)

我真的不明白我错过了什么,请帮帮我


编辑:我还试图像另一篇文章中所解释的那样显式公开ApplicationConversionService bean,但它不起作用,结果与以前完全相同。

好的,解决了,多亏了一个同事:它只是值后面的一个空格(很惊讶没有修剪空格!)

嗯,奇怪的行为。。。很高兴知道!即使application.properties中没有任何空格字符,我也会遇到相同的错误。。