【发布时间】:2017-12-26 19:09:26
【问题描述】:
我在 Eclipse 中有一个非常基本的 Maven 项目。我用一些新的依赖项更新了 pom,之后我就不能这样做了
mvn clean install
或
mvn compile
每次我得到
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project commons: Compilation failure: Compilation failure:
[ERROR] /path/to/my/class:[5,40] package org.springframework.test.context does not exist
[ERROR] /path/to/my/class:[8,2] cannot find symbol
[ERROR] symbol: class ActiveProfiles
但我的 pom 中有所需的依赖项,即
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.0.0.RELEASE</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
我知道范围是测试
<scope>test</scope>
但这在构建过程中应该不重要吧?最重要的是,我在 IDE 中看不到任何编译错误。我正在使用日食火星。
如何才能成功构建?
【问题讨论】:
-
你的班级在
src/test/java吗? -
在构建过程中应该不重要:当然重要。范围测试的依赖项用于编译测试类,而不是生产类。 Eclipse 无法进行区分,这就是为什么您在 Eclipse 中没有问题。