spring 引导读取不正确 属性 根据配置文件

spring boot is not reading correct property according profile

我的 Spring 引导应用程序是使用以下参数从命令行启动的

--spring.profiles.active=dev

两个 属性 文件位于资源文件夹中:

application.properties

application_dev.properties

在我的应用程序中,我有一个 Spring 组件,它使用以下

从 属性 文件中读取

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

private String remoteHost;

问题是默认 属性 文件 (application.properties) 的值分配给变量 remoteHost,而不是 属性 文件 application_dev.properties

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