02_SpringBoot多环境配置

一、源码地址

https://github.com/dianjiu/spring-boot-learn

https://gitee.com/dianjiu/spring-boot-learn

https://gitee.com/point9/spring-boot-learn

二、目录结构

 三、源码介绍

主配置文件 application.yml

spring:
  profiles:
    active: ${cfg.env}

本地环境 application-local.yml

#服务端口号
server:
  port: 8080 #原来是http的8080

spring:
  application:
    name: dianjiu-blog
  profiles: local #开发环境

四、本地环境启动

package cn.point9.config;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringBootConfigApplication {

    public static void main(String[] args) {
        System.setProperty("cfg.env","local");
        SpringApplication.run(SpringBootConfigApplication.class, args);
    }

}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章