自定义名称的配置文件的加载:
package com.flint.main; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; @SpringBootApplication public class MyConfigApp { public static void main(String[] args) { new SpringApplicationBuilder(MyConfigApp.class).properties( "spring.config.location=classpath:/flint.properties").run(args); } }
yml 配置文件的profile
package com.flint.main; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; @SpringBootApplication public class MyConfigAppProfile { public static void main(String[] args) { new SpringApplicationBuilder(MyConfigAppProfile.class).properties( "spring.profiles.active=windows").run(args); } }
原文地址:https://www.cnblogs.com/fjinlong/p/8302628.html
时间: 2024-10-21 17:29:54