简体   繁体   中英

spring boot is not reading correct property according profile

My Spring boot application is started from the command line with the following parameters

--spring.profiles.active=dev

Two property files are located in the resource folder :

application.properties

application_dev.properties

In my application I have a Spring Component which reads from the property file using the following

@Value("${ch.admin.host}")

private String remoteHost;

The problem is that the value of the default property file (application.properties) is assigned to the variable remoteHost, and not the value of the property file application_dev.properties

您应该将文件更改为application-dev.properties。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM