我正在从外部文件设置我的数据库属性,并尝试对活动配置文件执行相同的操作,但没有任何运气。
如果尝试在 app.propertiesspring.config.location= C:\\run\\secrets\\test
中:但这不起作用。
在我尝试过读取数据库属性的同一个配置文件中:
@Component
@Configuration
@PropertySource(value={"file:/run/secrets/file.properties"}, ignoreResourceNotFound = true)
public class AppProperties {
@Resource
private Environment env;
@Bean
public Properties props(){
Properties props = new Properties();
props.setProperty("spring.profiles.default", env.getRequiredProperty("spring.profiles.active"));
//props.put("spring.profiles.active", env.getRequiredProperty("spring.profiles.active"));
return props;
}
}
在我的外部文件中,我已经尝试
spring.profiles.active=dev
过spring.profiles.default=dev
似乎没有任何效果。