When you add an existing project to MAVEN management, there is always a lot of inexplicable problems, one of which is that MAVEN's default project structure is inconsistent with its own project structure, resulting in the inability to compile the source code, let alone deploy and run the project.
Java program Development, the general use of Eclipse, myeclipse and other tools, its source directory is SRC, which is different from the MAVEN default Src/main/java. Therefore, without additional configuration, the use of the MAVEN command cannot complete the compilation of the code.
In this case, Codehaus provides a build-helper-maven-plugin plug-in to support the customized project directory structure (as opposed to the MAVEN default directory structure).
The plugin's official website: http://mojo.codehaus.org/build-helper-maven-plugin/
Up to the present (2013-12-25), the latest version is 1.8
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId> build-helper-maven-plugin</artifactid>
<version>1.8</version>
</plugin>
The plug-in provides a number of goals, including setting up the main source directory, test source directory, master resource file directory, test resource file directory, and so on.
The following is a brief account of the main resource file directory, the main source directory configuration, the other settings are similar, no longer one by one to tell.
Directly on the code, the description is all in the comment.
<!--set up multiple source folders--> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactid>bui Ld-helper-maven-plugin</artifactid> <version>1.8</version> <executions> < !--Add the Master resource file directory--> <execution> <!--custom name, not repeatable--> <id>add-resource< ;/id> <!--Specifies the binding to the lifecycle--> <phase>initialize</phase> <!--Specifies the specified Target, you can add multiple--> <goals> <goal>add-resource</goal> </goals&
Gt
<configuration> <resources> <!--resource Files directory to add multiple-->
<resource> <directory>${basedir}/src/main/one</directory>
<!--whether to enable variable filtering--> <filtering>true</filtering> <!--Excluded files, can add multiple--> <excludes> <exclude>**/*.java</exc lude> </excludes> </resource> <res Ource> <directory>${basedir}/src/main/two</directory> & Lt;filtering>true</filtering> <excludes> <exclud
E>**/*.java</exclude> </excludes> </resource> </resources> </configuration> </execution> <!--Tim Add main source directory--> <execution> <id>add-source</id> <phase>initializ e</phase> <goals> <goal>add-source</goal> </goals > <cOnfiguration> <sources> <SOURCE>${BASEDIR}/SRC/MAIN/THREE</SOURC
E> <source>${basedir}/src/main/four</source> </sources> </configuration> </execution> <!--add Test source directory--> <executio
N> <id>add-test-source</id> <phase>initialize</phase> <goals> <goal>add-test-source</goal> </goals> <c Onfiguration> <sources> <source>${basedir}/src/main/five</source
> <source>${basedir}/src/main/six</source> </sources> </configuration> </execution> </executions> </plugin>
After you add the above configuration, you can compile the source code by executing the MAVEN command compile.