Spring Boot将自动解析application.properties文件中的任何${ENV}占位符,以及相应的环境变量.
但是,当我通过Quartz配置的Propertiesfactorybean文件提供quartz.properties时,不会发生这种解决方案.
@Bean
public Properties getQuartzProperties() throws IOException {
Propertiesfactorybean propertiesfactorybean = new Propertiesfactorybean();
propertiesfactorybean.setLocation(new ClassPathResource("/quartz.properties"));
propertiesfactorybean.afterPropertiesSet();
return propertiesfactorybean.getobject();
}
最佳答案
您可以声明一个新类来提供属性(使用@Configuration注释)并提及@PropertySource
@Configuration
@PropertySource("classpath:quartz.properties")
public class QuartzConfig {
//...
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。