2017-02-24 51 views
0

我有一个使用配置文件属性文件的spring boot 1.5.1项目。在我的/ src目录/主/资源我有我的所有属性文件 enter image description hereIntelliJ IDEA没有选择正确的应用程序 - {}。properties文件

使用的IntelliJ 2016年3月4日我设置

Run Configuration | Active Profile

为“本地”,并运行它。我看到这在控制台:

The following profiles are active: local

但在财产文件 data.count.users=2

,并用作值:

@Value("${data.count.users}") 
private int userCount; 

一个没有被拾起,并因此引起错误:

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'data.count.users' in string value "${data.count.users}"

但是,如果我通过gradle运行这个

bootRun { 
    systemProperty 'spring.profiles.active', System.properties['spring.profiles.active'] } 

gradle bootRun -Dspring.profiles.active=local

那么一切都启动时,使用本地配置文件预期。任何人都可以看到为什么这不被正确拾取?在IntelliJ项目结构中,我将my/src/main/resources定义为我的资源文件夹。

UPDATE:配置的

添加截图: enter image description here

回答

2
  1. 皮斯加春方面给你的Spring引导模块,以获得全面支持
  2. 是模块heimdall一个正确的类路径,即不它包含所示的resources文件夹与您的application.properties
  3. 如果这没有帮助,请在我们的错误跟踪器中提交一个最小示例项目来重现您的项目的确切结构,但调查https://youtrack.jetbrains.com/issues/IDEA的变量太多。
+0

这是它,设置春季方面是缺少的部分。我猜它在15和16之间有不同的存储? – sonoerin

2

我在这里可能是错的,但它看起来不像spring.profiles.active环境变量实际上是在您的配置中设置的,无论您选择什么作为活动配置文件。这可能是IntelliJ的一个错误。

但是,在运行 - >编辑配置中设置环境变量绝对适用于我。

enter image description here

+0

谢谢我在文件 - >设置对话框中尝试过,但没有奏效 – osmingo

相关问题