IntelliJ IDEA 编译maven项目以及运行测试前编译项目

Maven编译及命令行输出

右侧Maven Projects, 打开, 选取某个Project打开至Lifecycle/package 或其他任何一个lifecycle选项, 在上面右键Run Maven Build, 就可以看到编译输出.

1. Profile的选择: 打开最上面的Profiles, 勾选要使用的profile
2. 跳过test: 最上面的圆球加闪电的图标

运行Tomcat测试时的编译

点击打开Edit Run/Debug Configurations

1. 左侧栏, Defaults里面找到Maven, profiles里面填写要使用的profile, 注意这里会有hint提示.
2. 选择Tomcat Server下的tomcat实例, 在Deployment里加上要运行的Artifacts(注意修改application context)后, 回到Server tab, 在Before launch: Maven Goal, Build Artifacts里面, 添加Run Maven Goal, 编辑框里, Commandline 填写要执行的goal, 填写多个可以用空格分开, 例如填写 clean package . 如果要在编译时跳过不编译某个模块, 可以填写 clean package -pl !daemon 其中 daemon就是那个模块的名称. 把这一步放到Build 'xxx' artifact前面去. 在点运行或者测试Tomcat服务器时, 就会先run maven goal.

原文地址:https://www.cnblogs.com/milton/p/4749447.html