1. 程式人生 > >maven在打war包時將資原始檔打包到classes目錄下

maven在打war包時將資原始檔打包到classes目錄下

配置pom.xml在build裡面

 <!--將類檔案打成jar包-->

                            <archiveClasses>true</archiveClasses>

                            <!--將資原始檔打到classes目錄下-->

                            <webResources>

                                <resource>

                                    <directory>src/main/resources</directory>

                                    <targetPath>WEB-INF/classes</targetPath>

                                    <filtering>true</filtering>

                                </resource>

                            </webResources>


總體:

<!-- 外掛配置 -->
	<build>
		<plugins>
			<!-- compiler外掛, 設定JDK版本 -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.2</version>
				<configuration>
					<source>${java.version}</source>
					<target>${java.version}</target>
					<showWarnings>true</showWarnings>
				</configuration>
			</plugin>

			<!-- resource外掛 -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-resources-plugin</artifactId>
				<version>2.7</version>
			</plugin>

			<!-- war打包外掛, 設定war包名稱不帶版本號 -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.5</version>
				<configuration>
					<warName>${project.artifactId}</warName>
                            <!--將類檔案打成jar包-->

                            <archiveClasses>true</archiveClasses>

                            <!--將資原始檔打到classes目錄下-->

                            <webResources>

                                <resource>

                                    <directory>src/main/resources</directory>

                                    <targetPath>WEB-INF/classes</targetPath>

                                    <filtering>true</filtering>

                                </resource>

                            </webResources>

                        </configuration>
			</plugin>