peizhiwenjian

自定义配置文件

如果你不想使用application.properties作为配置文件,怎么办?完全没问题

java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties

或者

java -jar -Dspring.config.location=D:\config\config.properties springbootrestdemo-0.0.1-SNAPSHOT.jar 

当然,还能在代码里指定

 

@SpringBootApplication
@PropertySource(value={"file:config.properties"})
public class SpringbootrestdemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootrestdemoApplication.class, args);
    }
}

 或者

修改

在application.properties中支持指定j2cache配置文件,让你开发环境和生产环境分离

j2cache.config-location=/j2cache-${spring.profiles.active}.properties
/ABC/J/D/DEEE
j2cache.config-location=/classpath:config/jdbc222222.properties

posted @ 2018-08-29 22:24  bcombetter  阅读(176)  评论(0编辑  收藏  举报