SpringBoot项目配置多环境env

javaSpringBoot项目多环境配置

为什么

项目里面需要集成测试环境、开发、生产、多云环境,不仅需要application.yml,还需要加载别的config配置文件

故,我需要便捷多环境配置管理

maven Profiles 救命


项目的pom文件管理

复制代码
<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
        <!--uuuuu-->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
            <!-- 使用@@站位符,输出Dockerfile至docker文件夹 -->
            <resource>
                <directory>src/main/docker</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*</include>
                </includes>
                <targetPath>../docker</targetPath>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*</include>
                </includes>
                <excludes>
                    <exclude>env/**</exclude>
                    <exclude>.gitkeep</exclude>
                </excludes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources/env/${env}</directory>
            </resource>
        </resources>
    </build>
    <profiles>
        <profile>
            <id>dev</id>
            <properties>
                <env>dev</env>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>

        <profile>
            <id>test</id>
            <properties>
                <env>test</env>
            </properties>
        </profile>
        <profile>
            <id>xrytest</id>
            <properties>
                <env>xrytest</env>
            </properties>
        </profile>
        <profile>
            <id>prd</id>
            <properties>
                <env>prd</env>
            </properties>
        </profile>
    </profiles>
相关推荐
※DX3906※1 小时前
Java排序算法--全面详解面试中涉及的排序
java·开发语言·数据结构·面试·排序算法
cur1es2 小时前
【JVM类加载&双亲委派模型&垃圾回收机制】
java·jvm·gc·垃圾回收·类加载·双亲委派模型
Mr.朱鹏2 小时前
JVM-GC垃圾回收案例
java·jvm·spring boot·算法·spring·spring cloud·java-ee
焦糖玛奇朵婷2 小时前
实测扭蛋机小程序:开发简单,互动有趣
java·大数据·程序人生·小程序·软件需求
Nan_Shu_6142 小时前
学习: 尚硅谷Java项目之小谷充电宝(3)
java·后端·学习
wzqllwy2 小时前
8 大经典排序算法(Java 实现):原理 + Demo + 核心分析
java·算法·排序算法
智能工业品检测-奇妙智能2 小时前
AIFlowy如何实现与现有Spring Boot项目的无缝集成?
java·spring boot·后端
從南走到北2 小时前
JAVA无人共享无人健身房物联网结合系统源码支持小程序+公众号+APP+H5
java·物联网·小程序
Nuopiane2 小时前
MyPal3(3)
java·开发语言
Ama_tor2 小时前
Flask零基础进阶(中)
后端·python·flask