Maven :web專案同時打包成war和jar
阿新 • • 發佈:2019-01-06
在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>