Maven :web项目同时打包成war和jar

时间:2022-09-15 09:34:12

在pom.xml里配置

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<warName>ROOT</warName>
<archiveClasses>true</archiveClasses>
</configuration>
</plugin>

但是这样会把 src\main\resources 下的配置文件也打包进jar包,不方便部署时修改。

take it easy.有办法:


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<warName>ROOT</warName>
<archiveClasses>true</archiveClasses>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>src\main\resources</directory>
<targetPath>WEB-INF\classes</targetPath>
<!-- the list has a default value of ** -->
<includes>
<include>**</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>