我正在尝试运行请求工厂示例,但是,运行mvn clean install
时出现此错误。
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/carlos/workspace/requestfactory/tutorial/src/main/java/cleancodematters/requestfactory/tutorial/client/Tutorial.java:[74,53] cannot access javax.validation.ConstraintViolation
class file for javax.validation.ConstraintViolation not found
context.save( pizza ).fire( new Receiver<Void>() {
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
/home/carlos/workspace/requestfactory/tutorial/src/main/java/cleancodematters/requestfactory/tutorial/client/Tutorial.java:[74,53] cannot access javax.validation.ConstraintViolation
class file for javax.validation.ConstraintViolation not found
context.save( pizza ).fire( new Receiver<Void>() {
The code of the example can be found at github。我尝试了其他的例子,试图改变pom.xml
,我想我几乎尝试了所有的东西,而且我总是跳出同样的错误。
提前致谢。
答案 0 :(得分:4)
我认为问题与以下依赖关系有关:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<classifier>sources</classifier>
<scope>test</scope>
</dependency>
在第一个依赖项中,您使用的分类器“sources”根本没有意义。此外,范围“test”也没有意义,因为编译等需要这些类。所以你不应该使用范围。只需将其减少为以下单个依赖项:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
第二点是为什么你使用build-helper-plugin并添加一个不必要的补充文件夹,因为它已经由基于文档的maven-processor-plugin添加了。 将maven-war-plugin更新为最新(2.2)
是明智之举