Maven Spring JUnit 在Maven Clean Install时报
问题: Maven Clean Install时, 遇到报错package org.junit does not exist
明显, Unit Test在Compile阶段就被检查了.
而POM.xml里面配置的是:
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency>
所以导致问题发生.
但是为何在Compile阶段(而非Test Phase)就开始读Unit Test代码呢?
原因在于我错误的人为设置了Project的sourceDirectory,
<build> <finalName>demo</finalName> <sourceDirectory>src</sourceDirectory> <plugins> <plugin> ... </plugin> </plugins> </build>
参考自:
http://stackoverflow.com/questions/28173431/maven-error-package-org-junit-does-not-exist