Reputation: 1
I have been facing the issue with external configuration files to the classpath in spring boot, But it's not picking application.properties, application-dev properties from the external config folder. It's picking the database properties and XML files from the external config folder.I have tried the below approaches, can you please help me to resolve this issue.
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" />
Upvotes: 0
Views: 607
Reputation: 42441
I assume by "external configurations" you mean the configuration files (*.properties
, *.yml
, etc) that are not packaged into the spring boot artifact (Jar in your example)
In this case, they are by definition not in the classpath
of the application.
So to paraphrase, you are asking how to supply external configuration files to spring application. As you've found out already, indeed --spring.config.location
is the way to go:
--spring.config.location=file:/work/config1.yml,file:/work/config2.yml
Upvotes: 1