覆盖 application.properties 中的 Jackson 配置,即
spring.jackson.mapper.accept-case-insensitive-properties=false
导致应用程序无法启动并出现以下错误:
$ java -Duser.language=tr -jar springboot-localebugdemo-0.0.1-SNAPSHOT.jar
20:45:12.014 [main] INFO springboot.localebugdemo.LocaleBugDemoApplication - user.language=tr
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.10.RELEASE)
2018-02-25 20:45:12.683 INFO 3448 --- [ main] s.l.LocaleBugDemoApplication : Starting LocaleBugDemoApplication on DanBarMBP with PID 3448 (/Users/danbar/Projects/lab/springboot-localebugdemo/build/libs/springboot-localebugdemo-0.0.1-SNAPSHOT.jar started by danbar in /Users/danbar/Projects/lab/springboot-localebugdemo/build/libs)
2018-02-25 20:45:12.684 DEBUG 3448 --- [ main] s.l.LocaleBugDemoApplication : Running with Spring Boot v1.5.10.RELEASE, Spring v4.3.14.RELEASE
2018-02-25 20:45:12.684 INFO 3448 --- [ main] s.l.LocaleBugDemoApplication : No active profile set, falling back to default profiles: default
2018-02-25 20:45:14.157 INFO 3448 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-02-25 20:45:14.159 INFO 3448 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27
2018-02-25 20:45:14.267 INFO 3448 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-02-25 20:45:14.489 ERROR 3448 --- [ main] o.s.b.b.PropertiesConfigurationFactory : Properties configuration failed validation
2018-02-25 20:45:14.490 ERROR 3448 --- [ main] o.s.b.b.PropertiesConfigurationFactory : Field error in object 'spring.jackson' on field 'null': rejected value [accept-case-insensitive-properties]; codes [typeMismatch.spring.jackson.null,typeMismatch.null,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.jackson.null,null]; arguments []; default message [null]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'com.fasterxml.jackson.databind.MapperFeature' for property 'null'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [com.fasterxml.jackson.databind.MapperFeature] for value 'accept-case-insensitive-properties'; nested exception is java.lang.IllegalArgumentException: No enum constant com.fasterxml.jackson.databind.MapperFeature.accept-case-insensitive-properties]
2018-02-25 20:45:14.492 WARN 3448 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'standardJacksonObjectMapperBuilderCustomizer' defined in class path resource [org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration.class]: Unsatisfied dependency expressed through method 'standardJacksonObjectMapperBuilderCustomizer' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties': Could not bind properties to JacksonProperties (prefix=spring.jackson, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is org.springframework.validation.BindException: org.springframework.boot.bind.RelaxedDataBinder$RelaxedBeanPropertyBindingResult: 1 errors
Field error in object 'spring.jackson' on field 'null': rejected value [accept-case-insensitive-properties]; codes [typeMismatch.spring.jackson.null,typeMismatch.null,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.jackson.null,null]; arguments []; default message [null]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'com.fasterxml.jackson.databind.MapperFeature' for property 'null'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [com.fasterxml.jackson.databind.MapperFeature] for value 'accept-case-insensitive-properties'; nested exception is java.lang.IllegalArgumentException: No enum constant com.fasterxml.jackson.databind.MapperFeature.accept-case-insensitive-properties]
2018-02-25 20:45:14.495 INFO 3448 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-02-25 20:45:14.521 ERROR 3448 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Binding to target org.springframework.boot.autoconfigure.jackson.JacksonProperties@4b4523f8 failed:
Property: spring.jackson.null
Value: accept-case-insensitive-properties
Reason: Failed to convert property value of type 'java.lang.String' to required type 'com.fasterxml.jackson.databind.MapperFeature' for property 'null'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [com.fasterxml.jackson.databind.MapperFeature] for value 'accept-case-insensitive-properties'; nested exception is java.lang.IllegalArgumentException: No enum constant com.fasterxml.jackson.databind.MapperFeature.accept-case-insensitive-properties
Action:
Update your application's configuration
相同的应用程序,开始user.language=en
(也尝试了一些其他语言)工作正常。似乎任何 Spring Boot 应用程序(即使是新生成的,如附件 zip 中的应用程序)都会受到影响。