2017-05-11 2 views
0

Ich kann TestingServer in meinen externen Bibliotheken finden (siehe Screenshot unten), aber warum kann ich es nicht importieren? Ist die Bibliothek curator-test nicht in meinem Klassenpfad?IntelliJ IDEA kann TestingServer auf meinem Klassenpfad nicht finden

Ich verwende:
• IntelliJ Idea                   2017.1.2
• Frühling Stiefel                 1.5.3.RELEASE
• Apache Kuratorin     2.11.1

Meine pom.xml sieht wie folgt aus.

<?xml version="1.0" encoding="UTF-8"?> 
<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>org.fan.curator</groupId> 
    <artifactId>fan-curator-demo01</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>fan-curator-demo01</name> 
    <description>Demo project for Spring Boot</description> 

    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.5.3.RELEASE</version> 
     <relativePath/> <!-- lookup parent from repository --> 
    </parent> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
     <java.version>1.8</java.version> 
     <spring-cloud.version>Dalston.RELEASE</spring-cloud.version> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.springframework.cloud</groupId> 
      <artifactId>spring-cloud-starter-zookeeper-config</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.apache.curator</groupId> 
      <artifactId>curator-test</artifactId> 
      <version>2.11.1</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-test</artifactId> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 

    <dependencyManagement> 
     <dependencies> 
      <dependency> 
       <groupId>org.springframework.cloud</groupId> 
       <artifactId>spring-cloud-dependencies</artifactId> 
       <version>${spring-cloud.version}</version> 
       <type>pom</type> 
       <scope>import</scope> 
      </dependency> 
     </dependencies> 
    </dependencyManagement> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

 

Das sind meine externen Bibliotheken in IntelliJ IDEA.

Screenshot of External Libraries in IntelliJ IDEA

 

Dies ist der Fehler, den ich bekommen; TestingServer kann nicht importiert werden.

Screenshot of error showing TestingServer cannot be imported

Antwort

0

Ich finde heraus, warum. Spring boot machen die curator-test 's scope test (ich weiß nicht warum). Also füge ich einen compile Bereich zu seinem Artefakt hinzu, und es ist jetzt in Ordnung.

+0

Scope "Test" ist korrekt, da dies normalerweise nur zum Testen verwendet wird. – Randgalt

Verwandte Themen