一、Maven默認是源代碼是src/main/javajava
<build> <!--默認源代碼目錄--> <sourceDirectory>src/main/java </sourceDirectory> <!--默認測試源代碼目錄--> <testSourceDirectory>src/test/java</testSourceDirectory> <!--默認資源目錄--> <resources> <resource> <directory>src/main/resources</directory> </resource> </resources> <!--默認測試資源目錄--> <testResources> <testResource> <directory>src/test/resources</directory> </testResource> </testResources> </build>
二、修改POM文件,造成多源代碼maven
<build> <plugins> <!-- 指定多個源代碼目錄、多個資源文件目錄 --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.8</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>src/java/main</source> <source>src/java/generated</source> </sources> </configuration> </execution> </executions> </plugin> </plugins> </build>
三、項目結構測試