鼠标右键点击 pom.xml文件
选择 [Run As] ---[Maven build...]
在弹出的对话框中
Goals : clean install
Profiles: 什么都不用填写
(生成的war包在target目录的下面)
有的时候,我们需要传递参数
导出war时,导出不同的配置文件
我们还可以这么写
clean install -P test
代码如下
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<warSourceExcludes>WEB-INF/config/spring/dev/*.*,WEB-INF/config/spring/test/*.*</warSourceExcludes>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
<webResources>
<resource>
<directory>src/main/webapp/WEB-INF/config/spring/${package.environment}</directory>
<targetPath>WEB-INF/config/spring</targetPath>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
<profiles>
<profile>
<!-- 本地开发环境 -->
<id>dev</id>
<properties>
<package.environment>dev</package.environment>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<!-- 测试环境 -->
<id>test</id>
<properties>
<package.environment>test</package.environment>
</properties>
</profile>
</profiles>