Java로 작성된 일부 오픈 소스 소프트웨어를 다운로드하고 Eclipse를 사용하여 컴파일하려고 시도했습니다. 일부 파일에서 " '클래스 이름'유형의 계층 구조가 일치하지 않습니다 " 라는 오류가 발생했습니다 . 이러한 오류의 원인은 무엇이고 어떻게 해결합니까?
Java로 작성된 일부 오픈 소스 소프트웨어를 다운로드하고 Eclipse를 사용하여 컴파일하려고 시도했습니다. 일부 파일에서 " '클래스 이름'유형의 계층 구조가 일치하지 않습니다 " 라는 오류가 발생했습니다 . 이러한 오류의 원인은 무엇이고 어떻게 해결합니까?
답변:
존재하지 않는 인터페이스를 구현하려고하거나 존재하지 않는 클래스를 확장하고 있음을 의미합니다.
Eclipse를 새로 고치십시오.
작동하지 않으면 빌드 경로에없는 JAR에 대한 참조가 있음을 의미 할 수 있습니다. 프로젝트의 클래스 경로를 확인하고 인터페이스 또는 클래스를 포함하는 jar이 포함되어 있는지 확인하십시오.
내가 한 건 더 있어요 올바른 프로젝트 경로를 제공하고 이클립스로 가져 오십시오.
그런 다음 프로젝트-> 정리-> 모든 프로젝트 정리로 이동하십시오.
오류 : "클래스 이름"유형의 계층 구조에 일관성이없는 오류가 있습니다.
해결책 : class OtherDepJar {}->는 "other.dep.jar" 안에 있습니다.
DepJar 클래스 확장 OtherDepJar {}->는 "dep.jar" 안에 있습니다.
ProblematicClass 확장 DepJar {}->는 현재 프로젝트 안에 있습니다.
dep.jar이 프로젝트의 클래스 경로에 있지만 other.dep.jar이 프로젝트의 클래스 경로에없는 경우 Eclipse는 "유형의 계층 구조 ... 일관되지 않은 오류"를 표시합니다.
나에게 문제는 잘못된 수입 때문이었습니다. 실제로 v7 지원 라이브러리를 추가 한 후 가져 오기를 업데이트해야합니다.
프로젝트의 각 클래스에 대해 다음과 같이 수행하여 수정할 수 있습니다 .
import android.[*]각 클래스 에서을 사용하여 모든 행을 삭제하십시오.android.support.[*](및 아님 android.[*]).내 maven pom.xml에없는 종속성이 없기 때문입니다.
예를 들어, 광대역 전자 상거래 데모 사이트 구현을위한 통합 테스트를 만들고 싶었습니다.
구성 파일과 기본 테스트 클래스를 재사용하기 위해 broadleaf 상거래의 통합 테스트가 포함 된 broadleaf jar을 포함 시켰습니다. 이 프로젝트에는 포함되지 않은 다른 테스트 종속성이 있으며 "일관되지 않은 계층 구조"오류가 발생했습니다.
broadleaf / pom.xml 및 broadleaf / pom.xml의 각 종속성에 대한 버전을 제공하는 연관된 특성 변수에서 "테스트 종속성"을 복사 한 후 오류가 사라졌습니다.
속성은 다음과 같습니다.
<geb.version>0.9.3</geb.version>
<spock.version>0.7-groovy-2.0</spock.version>
<selenium.version>2.42.2</selenium.version>
<groovy.version>2.1.8</groovy.version>
종속성은 다음과 같습니다.
<dependency>
<groupId>org.broadleafcommerce</groupId>
<artifactId>integration</artifactId>
<type>jar</type>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.broadleafcommerce</groupId>
<artifactId>broadleaf-framework</artifactId>
<version>${blc.version}</version><!--$NO-MVN-MAN-VER$ -->
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>com.icegreen</groupId>
<artifactId>greenmail</artifactId>
<version>1.3</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>2.5.1</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymockclassextension</artifactId>
<version>2.4</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.9</version>
<type>jar</type>
<classifier>jdk15</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gebish</groupId>
<artifactId>geb-core</artifactId>
<version>${geb.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gebish</groupId>
<artifactId>geb-spock</artifactId>
<version>${geb.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>${spock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>${selenium.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>${selenium.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>${selenium.version}</version>
<scope>test</scope>
</dependency>
<!-- Logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.12</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.6.1</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.1</version>
<type>jar</type>
<scope>test</scope>
</dependency>
확장 클래스에 문제가 있으면 위의 오류 메시지가 표시됩니다.
예
class Example extends Example1 {
}
문제를 해결하다 Example1
나는이 문제도 가지고 있었다 ... 나는이 예외를 던지고있는 클래스의 계층 구조가 일식에 의해 루트 클래스로 다시 추적 될 수 없다는 것을 알았습니다 ...
내 경우에는 A, B 및 C의 3 가지 Java 프로젝트가 있습니다 .A 및 B는 maven 프로젝트이고 C는 일반 Java Eclipse 프로젝트입니다.
프로젝트 A에는 인터페이스 "interfaceA"가 있습니다 ... 프로젝트 B에는 인터페이스 "interfaceB"를 확장하는 인터페이스 "interfaceB"가 있습니다. 프로젝트 C에는 "interfaceB"를 구현하는 콘크리트 클래스 "classC"가 있습니다.
"프로젝트 C"는 빌드 경로에 "프로젝트 B"를 포함하고 있지만 "프로젝트 A"는 포함하지 않았습니다 (그래서 오류의 원인이되었습니다) .... "C"의 빌드 경로 내에 "프로젝트 A"를 포함시킨 후 모든 것이 정상으로 돌아 왔습니다 ...
Maven> 를 수행하는 것이 었습니다Download Source.