2012-08-06 171 views
37

我已经添加了对我的maven项目的配置文件。maven的默认构建配置文件

 <profile> 
      <id>da</id>     
     </profile> 
     <profile> 
      <id>live</id> 
     </profile> 
     <profile> 
      <id>dev</id> 
     </profile> 

当我在没有指定构建配置文件的情况下给出mvn clean install命令时。我需要默认构建dev配置文件。

我该如何做到这一点?

回答

81

通过使用属性activeByDefault当与-P参数没有选择其他的个人资料,你将能够在Maven中选择一个默认的配置文件。

<profiles> 
    <profile> 
     <id>da</id>     
    </profile> 
    <profile> 
     <id>live</id> 
    </profile> 
    <profile> 
     <id>dev</id> 
     <activation> 
      <activeByDefault>true</activeByDefault> 
     </activation> 
    </profile> 
<profiles> 

Maven Introduction to Profiles documentation

+2

@Freriko你说的没错,但请多一点点....健谈。下一次,解释什么属性是线索。 – 2012-08-06 08:26:23

+0

谨防[是否使用activeByDefault违背Maven的最佳实践?](http://stackoverflow.com/questions/16167206/does-using-activebydefault-go-against-maven-best-practices) – Vadzim 2017-01-23 13:27:52