Maven 多profile及指定编译问题

要点:

  1. 项目A依赖项目B,项目A、B都有对应的多个profile,通过mvn –P参数指定profile,只对A生效,对B不生效
  2. 项目A、B模块位于同一父项目,父项目构建时指定profile,可以传给A,B项目,A、B都使用同一指定的profile。
  3. 也可在父项目中定义属性,激活子项目profile,意即父项目 profile属性可传给各个子项目。
  4. 项目中定义的profile, 若设置为false,则不指定profile的情况下,该profil不会被执行。

实例:

项目A 定义2个profile(aprofile、bprofile), 项目B定义2个对应的profile(aprofile、bprofile),则可将项目A、B中的aprofile激活方式设置为:

true

bprofile profile激活方式设置为:  

 
	                     
		bprofile                
	            

编译项目A时使用参数可编译bprofile版本:

mvn clean install -Dbprofile

编译项目A时不带参数可编译aprofile版本:

mvn clean install

 

你可能感兴趣的:(JavaApp)