我希望遵循 Spring in Practice 第 10 章中关于使用 Maven 中的 Build Helper 插件为单元测试和集成测试创建单独目录的建议。我正在使用 Spring Tool Suite 尝试将集成测试添加到 Spring 项目中。我配置插件如下:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-it-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/it/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-it-resource</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/it/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
我使用 clean 运行构建,然后仅使用 compile 再次尝试。我在控制台屏幕上收到以下信息:
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building wellness Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- build-helper-maven-plugin:1.9.1:add-test-source (add-it-source) @ wellness ---
[INFO] Test Source directory: /Users/walk12/Documents/workspace-sts/wellness/src/it/java added.
[INFO]
[INFO] --- build-helper-maven-plugin:1.9.1:add-test-resource (add-it-resource) @ wellness ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ wellness ---
[WARNING] Using platform encoding (US-ASCII actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ wellness ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding US-ASCII, i.e. build is platform dependent!
[INFO] Compiling 6 source files to /Users/walk12/Documents/workspace-sts/wellness/target/classes
[WARNING] /Users/walk12/Documents/workspace-sts/wellness/src/main/java/com/kylewalker/wellness/data/EmployeeDaoJdbcImpl.java: /Users/walk12/Documents/workspace-sts/wellness/src/main/java/com/kylewalker/wellness/data/EmployeeDaoJdbcImpl.java uses unchecked or unsafe operations.
[WARNING] /Users/walk12/Documents/workspace-sts/wellness/src/main/java/com/kylewalker/wellness/data/EmployeeDaoJdbcImpl.java: Recompile with -Xlint:unchecked for details.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.374 s
[INFO] Finished at: 2014-10-18T07:48:37-07:00
[INFO] Final Memory: 15M/153M
[INFO] ------------------------------------------------------------------------`
据说“添加了/Users/walk12/Documents/workspace-sts/wellness/src/it/java”,但我的实际文件结构似乎没有任何变化。我应该在某处看到“src/it/java”,对吗?相反,即使在关闭并打开项目并点击刷新之后,我得到的只是: