は、私は次のテストの依存関係をインポートしない場合は、私のテストケースでのコンパイルエラーに直面しています、春・ブート・スターターの依存関係を持つスプリングブートアプリケーションを実行していますSpring-boot-starter-parentには、Spring-boot-testの依存関係を手動でインポートする必要があります。
- 春ブートテスト
- 春試験
- assertjコア
私の理解では、これらは、ばねブートスタータ親に既に存在していると私はあまりにもそれらを見ることができるということです。しかし、コンパイル時エラーの私は以下の通りのpom.xmlにインポートすることを強制していますが、その後、私は
複製は春ブートテストのバージョン1.5.6.RELEASEを管理していることの警告を取得
複製は、ばねテスト
のバージョン4.3.10.RELEASEを管理し、assertjコア用similiarly
あなたは警告が、ここでのpom.xmlに 発生した場所を見ることができますコンパイルエラーは、私がテストの依存関係を含めいけない場合は、以下の場合に発生私のコードの
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<json.version>20160810</json.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>4.6.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<version>1.5.6.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.3.10.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>${json.version}</version>
</dependency>
部品を次のように
そして、私のpom.xmlです。 @SpringBootTestとTestRestTemplateは、依存関係が存在しない場合はインポートできません。
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import com.fasterxml.jackson.core.JsonProcessingException;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class MatchControllerTest {
// Test RestTemplate to invoke the APIs.
@Autowired
private TestRestTemplate testRestTemplate;
//....and other part of the code
どうしてですか?
- それらは既にばねブートスタータ親
- 中に存在する場合、なぜ手動のpom.xmlに含まれる有するテスト依存関係が一旦含まれ、それは(duplcating管理バージョン警告が表示されていますおそらく正しく...)。
私はおそらく何かばかげている/間違っている - 助けてください!
はjars wouldntが正しくダウンロードされているか、mvn clean installを実行するか、Mavenリポジトリ(.m2)フォルダの下に移動し、ダウンロードしたjarに問題がないかどうかを確認してください。単純に削除して、プロジェクト - > Maven - >プロジェクトを更新してください。 – Barath