我有一个关于这个 pom 的小项目......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.shipcloud</groupId>
<artifactId>shipcloud-api</artifactId>
<description>The Java API for ShipCloud.</description>
<version>1.0-SNAPSHOT</version>
<prerequisites>
<maven>3.0</maven>
</prerequisites>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.compiler.source.version>1.8</project.compiler.source.version>
<project.compiler.target.version>1.8</project.compiler.target.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<!-- More Matchers than the default version in JUnit -->
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.2.0.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>2.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
在 Eclipse 中,一切正常,测试工作(使用 maven 找不到的那个类),但是当我尝试通过 maven 清理安装它时,我得到一个错误,它AbstractCharSequenceAssert
在这一行中找不到(AssertJ 的一部分)(这是低于另一个公共类的类):
class UrlParameterStringAssert extends AbstractCharSequenceAssert<UrlParameterStringAssert, String> {
信息]------------------------------------------------ ------------- [错误] 编译错误:
[信息] ---------------------------- -------------------------------- [错误] /home/fschaetz/workspaces/workspace5/.../shipcloud- api/src/test/java/com/example/shipcloud/rest/shipcloud/domain/AddressSearchFieldsTest.java:[103,39] 错误:找不到符号 [ERROR] 符号:类 AbstractCharSequenceAssert
我查看了调试输出,在运行 testCompile 时,AssertJ jar 实际上位于提供给编译器的类路径中:
-classpath ...:/home/fschaetz/.m2/repository/org/assertj/assertj-core/2.2.0/assertj-core-2.2.0.jar:...
(该文件存在,可读,包含类并且在 Eclipse 中工作正常)。
我已经尝试过干净(maven/eclipse),在项目上运行更新等,但似乎没有任何效果。当我尝试在 jenkins 中运行 maven 安装时,也会发生同样的事情,顺便说一句。
制造麻烦的类的进口是......
import static de.assona.rest.shipcloud.domain.UrlParameterStringAssert.assertThat;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.assertj.core.api.AbstractCharSequenceAssert;
import org.junit.Before;
import org.junit.Test;
有任何想法吗?