标签:dde lob text getenv image date AC 逗号 com
1、设置编译器,找到1,点击2
2、输入设置命令:--spring.profiles.active=test,如果是多个文件输入--spring.profiles.active=test,dev
3、测试运行
1 package com.springboot; 2 3 import com.springboot.conf.*; 4 import org.springframework.boot.SpringApplication; 5 import org.springframework.boot.autoconfigure.SpringBootApplication; 6 import org.springframework.context.ConfigurableApplicationContext; 7 8 /****************************** 9 * @Author : liuyang 10 * @ClassName : QuickStartApplication 11 * @Date : 2018 五月 20 12 * @Time : 01:05:59 13 * @Type : SpringBoot 14 * @Version : 1.0 15 * @Return : 16 * @Description : 17 *******************************/ 18 19 @SpringBootApplication 20 public class ReadDevOrTestApplication { 21 22 public static void main(String[] args) { 23 24 SpringApplication springApplication = new SpringApplication(ReadDevOrTestApplication.class); 25 26 //编译器配置,注释上两行,在Edit Configuration中加入--spring.profiles.active=test,启用多个逗号多个--spring.profiles.active=test,dev 27 28 29 ConfigurableApplicationContext applicationContext = springApplication.run(args); 30 31 // 读取其他配置文档 32 System.out.println("*********开发的配置文档是:" + applicationContext.getEnvironment().getProperty("jdbc.url")); 33 34 // 读取其他配置文档 35 System.out.println("*********开发的配置文档是:" + applicationContext.getEnvironment().getProperty("jdbc.name")); 36 37 applicationContext.close(); 38 } 39 }
相关代码:
https://github.com/liushaoye/quick_start/blob/second/src/main/java/com/springboot/ReadDevOrTestApplication.java
IntellJ IDEA 2017 激活编译器配置,读取多个配置文件
标签:dde lob text getenv image date AC 逗号 com
原文地址:https://www.cnblogs.com/liuyangfirst/p/9062915.html