【发布时间】:2017-05-17 09:03:11
【问题描述】:
我有一个带有占位符的 application.properties 文件的 Spring Boot 应用程序:
tommy.messagebroker.provider=activemq
tommy.messagebroker.tcpaddress=${JMS_HOST}
tommy.messagebroker.port=${JMS_PORT}
当我设置这些环境变量并运行应用程序时,它不会用这些占位符替换 env 变量的实际值...
这是我的主要应用程序类:
@SpringBootApplication
@ComponentScan(basePackages = {"com.tommy.server"})
public class tommyApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(AuditManagerApplication.class, args);
}
}
在我的 pom.xml 中:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.5.3.RELEASE</version>
</dependency>
有人知道如何实现这种替代吗?
【问题讨论】:
-
如何设置这些环境变量?
-
在运行应用程序之前将它们添加到 Intellij“编辑配置”菜单中...
-
请分享编辑配置截图
标签: spring spring-boot