Maven 为我们提供了一致的项目目录配置(源文件夹、资源文件夹等),在自动构建项目时, Maven 会按照这个配置来执行操作(编译源文件、拷贝资源文件)。
当 Maven 规约的默认配置不能够满足我们的需求时,我们就要动手修改项目的 Maven 配置,让我们的项目能够与 Maven 很好地协同工作。
1、配置多个classpath:这里使用了maven插件build-helper-maven-plugin
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.1</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>../../DF/query/src</source> <source>../../DM/domain/log/src</source> <source>../../DM/biz/log/src</source> <source>../../DM/biz/exam/src</source> <source>../../DM/biz/credit/src</source> </sources> </configuration> </execution> </executions> </plugin>
2、配置多个资源目录
<build> <resources> <resource> <directory>../../DM/biz/preq/src</directory> <filtering>true</filtering> <includes> <include>*.xml</include> <include>*.properties</include> </includes> </resource> <resource> <directory>../../DM/biz/preq/src</directory> <filtering>true</filtering> <includes> <include>*.xml</include> <include>*.properties</include> </includes> </resource> </resources> </build>