spring.config.location无法在spring boot 2.0.0 M6上运行

前端之家收集整理的这篇文章主要介绍了spring.config.location无法在spring boot 2.0.0 M6上运行前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在将我的一个微服务迁移到Spring Boot 2.0.0.M6,并且在命令行上使用–spring.config.location =选项时出现错误.错误如下:

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'property' in value "${property}"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:172) ~[spring-core-5.0.1.RELEASE.jar:5.0.1.RELEASE]
at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) ~[spring-core-5.0.1.RELEASE.jar:5.0.1.RELEASE]
at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:237) ~[spring-core-5.0.1.RELEASE.jar:5.0.1.RELEASE]
at org.springframework.core.env.AbstractPropertyResolver.resolverequiredPlaceholders(AbstractPropertyResolver.java:211) ~[spring-core-5.0.1.RELEASE.jar:5.0.1.RELEASE]
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175) ~[spring-context-5.0.1.RELEASE.jar:5.0.1.RELEASE]
at org.springframework.beans.factory.support.Abstractbeanfactory.resolveEmbeddedValue(Abstractbeanfactory.java:834) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
at org.springframework.beans.factory.support.DefaultListablebeanfactory.doResolveDependency(DefaultListablebeanfactory.java:1081) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
at org.springframework.beans.factory.support.DefaultListablebeanfactory.resolveDependency(DefaultListablebeanfactory.java:1060) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:578) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:367) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
... 50 common frames omitted

如果我不使用自定义属性文件,一切都按预期工作或使用RELEASE版本.我正在使用以下命令启动应用程序:

java -jar application.jar –spring.config.location = app.properties

更新

我注意到当使用这个选项时,Spring完全替换了项目中的默认application.properties,不同于以前只是覆盖参数文件中的属性的Spring版本.这是一个错误吗?

更新2

从团队中获得了response,显然这是预期的行为.试着现在知道是否有办法使用旧版本的行为.

最佳答案
正如Spring团队所说,使用spring.config.location中的旧行为的正确方法是使用新的spring.config.additional-location
原文链接:https://www.f2er.com/spring/432559.html

猜你在找的Spring相关文章