【问题标题】:IllegalArgumentException: Could not resolve placeholder 'example.property' in string value "${example.property}"IllegalArgumentException:无法解析字符串值“${example.property}”中的占位符“example.property”
【发布时间】:2016-11-21 09:32:52
【问题描述】:

我在那里使用的是 spring boot 1.4.0 一切正常,但我将 spring boot 更新到 1.4.2 并且发生异常后出现 booom。

IllegalArgumentException:无法解析字符串值“${example.property}”中的占位符“example.property”

我再次将版本降级到 1.4.0,它正在工作。

我已将属性文件放在 jar 外,并使用 spring.config.location 提供 example.yml 文件路径,我在 STS(eclipse) 运行配置的帮助下保存属性。

参数名称:spring.config.location

值:文件:/home/project/application-property.yml,文件:/home/project/email-property.yml

以下是春季属性的使用,

@Service("myService")
public class MyServiceImpl implements MyService {

  @Value("${example.property}")
  private String someProperty;

  ....
}

以下是我的应用程序类(不是我用于配置的单个 xml 文件),

@SpringBootApplication
public class WebApplication
{
  public static void main(String[] args)
  {
    SpringApplication.run(WebApplication.class, args);
  }
}

spring-boot 1.4.2相关属性访问是否有变化。我应该怎么做才能让它发挥作用?

【问题讨论】:

  • 能否请您分享您的 config.location 和 pom.xml 中的 bootstrap.yml、Application.yml 以便我们分析问题?

标签: spring-boot


【解决方案1】:

以下解决方案对我有用,

STS/eclipse运行配置添加运行时参数,

参数名称run.arguments

: "--spring.config.location=file:/home/project/application-property.yml", "--spring.config.location=file:/ home/project/mail-property.yml"

注意:如果您查看值,它的双引号逗号分隔的文件列表

但真的不知道为什么这个解决方案有效,而不是一个有问题的解决方案。如果知道原因,请发表评论。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-23
    • 2017-03-13
    • 1970-01-01
    • 1970-01-01
    • 2018-04-24
    • 2018-06-17
    • 1970-01-01
    相关资源
    最近更新 更多