找到類我有這個POM一個小項目...Maven的測試編譯不會在類路徑
<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的安裝,我得到一個錯誤,它不能在此行中找到AssertJ)的AbstractCharSequenceAssert
(部分(即低於另一個公共類的類):
class UrlParameterStringAssert extends AbstractCharSequenceAssert<UrlParameterStringAssert, String> {
INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR :
[INFO] ------------------------------------------------------------ [ERROR] /home/fschaetz/workspaces/workspace5/.../shipcloud-api/src/test/java/com/example/shipcloud/rest/shipcloud/domain/AddressSearchFieldsTest.java:[103,39] error: cannot find symbol [ERROR] symbol: class AbstractCharSequenceAssert
我有looke通過調試輸出d和運行testCompile時,該AssertJ罐子實際上是向編譯器類路徑:
-classpath ...:/home/fschaetz/.m2/repository/org/assertj/assertj-core/2.2.0/assertj-core-2.2.0.jar:...
(該文件存在,是可讀的,包含類和在Eclipse中正常工作)。
我試過乾淨(maven/eclipse),在項目上運行更新等,但似乎沒有任何工作。當我嘗試在jenkins中運行maven install時,發生同樣的事情,順便說一句。
,使麻煩是類的進口...
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;
任何想法?
你可以發佈類AddressSearchFieldsTest的導入嗎? – Tunaki
UrlParameterStringAssert是你自己的類還是由AssertJ提供? –
我的。我擴展了'AbstractCharSequenceAssert'來做我自己的一些斷言魔術。 –