Maven高级——多环境配置与应用

风陵南·2023-03-27 16:31·80 次阅读

Maven高级——多环境配置与应用

多环境配置与应用

 

开发步骤#

  • 定义多环境
    <!--配置多环境-->
    <profiles>
    <!--开发环境-->
    <profile>
    <id>env_dep</id>
    <properties>
    <jdbc.url>jdbc:mysql://127.0.0.1:3306/ssm_db</jdbc.url>
    </properties>
    <!--设置为默认启动环境-->
    <activation>
    <activeByDefault>true</activeByDefault>
    </activation>
    </profile>
    <!--生产环境-->
    <profile>
    <id>env_pro</id>
    <properties>
    <jdbc.url>jdbc:mysql://127.2.2.2:3306/ssm_db</jdbc.url>
    </properties>
    </profile>
    <!--test环境-->
    <profile>
    <id>env_test</id>
    <properties>
    <jdbc.url>jdbc:mysql://127.3.3.3:3306/ssm_db</jdbc.url>
    </properties>
    </profile>
    </profiles>
  • 使用多环境(构建过程)

  

  

  如:mvn install -P env_test

 

跳过测试#

  • 应用场景
    • 功能更新中并且没有开发完毕
    • 快速打包
    • ...

 

  • 跳过测试指令

  mvn 指令 -D skipTests

    • 范例

    mvn package -D skipTests

  • 细粒度控制跳过测试
    <plugins>
    <plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.12.4</version>
    <configuration>
    <skipTests>false</skipTests>
    <!--排除掉一些不参与测试的内容-->
    <excludes>
    <exclude>**/BookServiceTest.java</exclude>
    </excludes>
    </configuration>
    </plugin>
    </plugins>

  

 

posted @   风陵南  阅读(80)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
目录
点击右上角即可分享
微信分享提示