【发布时间】:2019-11-09 00:21:06
【问题描述】:
我一直面临 Spring Boot 中类路径的外部配置文件的问题,但它没有从外部配置文件夹中选择 application.properties、application-dev 属性。它正在从外部配置文件夹中选择数据库属性和 XML 文件。我尝试了以下方法,请你帮我解决这个问题。
java -cp ./config/;./lib/ips--0.0.1-SNAPSHOT.jar java -cp ./config/;./lib/ips-rest-0.0.1-SNAPSHOT.jar java -jar ./lib/ips-rest-0.0.1-SNAPSHOT.jar --spring.config.location=classpath:/config/,file:./config/,classpath:/,file:./
@ImportResource("classpath:ips-spring.xml")
@SpringBootApplication(exclude = { KafkaAutoConfiguration.class })
@ComponentScan(value = "com.mark", useDefaultFilters = false)
@EnableAutoConfiguration
@EnableConfigurationProperties
public class ApplicationRest {
public static void main(String[] args) {
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(ApplicationRest.class, args);
System.out.println("Started ApplicationRest");
}
}
<context:property-placeholder location="classpath:env.properties,classpath:db.properties" ignore-resource-not-found="false" ignore-unresolvable="false" />
<import resource="classpath:app-entity.xml" />
【问题讨论】:
-
你试过
@PropertySource吗?
标签: java spring spring-boot