IT박스

Eclipse 컴파일 오류 : '클래스 이름'유형의 계층 구조가 일치하지 않습니다

itboxs 2020. 6. 25. 21:39
반응형

Eclipse 컴파일 오류 : '클래스 이름'유형의 계층 구조가 일치하지 않습니다


Java로 작성된 일부 오픈 소스 소프트웨어를 다운로드하고 Eclipse를 사용하여 컴파일하려고했습니다. 일부 파일에서 " '클래스 이름'유형의 계층 구조가 일치하지 않습니다 " 라는 오류가 발생했습니다 . 이러한 오류의 원인은 무엇이고 어떻게 해결합니까?


존재하지 않는 인터페이스를 구현하려고하거나 존재하지 않는 클래스를 확장하고 있음을 의미합니다.

Eclipse를 새로 고치십시오.

작동하지 않으면 빌드 경로에없는 JAR에 대한 참조가 있음을 의미 할 수 있습니다. 프로젝트의 클래스 경로를 확인하고 인터페이스 또는 클래스를 포함하는 jar이 포함되어 있는지 확인하십시오.


때로는 필요한 항아리를 추가 할 때 발생하지만 IT에 필요한 항아리는 포함하지 않습니다. 내 경우에는 tomcat / lib에 모든 항아리를 추가하면이 문제를 해결하는 데 도움이되었습니다. 웹 응용 프로그램을 작성 중입니다.


오류를 확인하십시오 ( "마커"탭). 나는 또한 다음과 같은 오류가 있었다 :

프로젝트에서 필요한 라이브러리의 아카이브를 읽을 수 없습니다 ...

그것이 수정되었을 때 "일관되지 않은 오류"가 사라졌습니다.

실제로 빌드 경로에 항아리를 추가했지만 어떤 이유로 오류와 함께 읽을 수 없습니다

프로젝트의 필수 라이브러리에 대한 아카이브를 읽을 수 없거나 유효한 ZIP 파일이 아닙니다.

대신 "외부 항아리"로 추가했습니다. 도움이되었고 모든 컴파일 문제는 더 이상 없었습니다!


JDK를 새 버전으로 업그레이드 한 후이 문제가 발생했습니다. 프로젝트 속성 / Java 빌드 경로에서 라이브러리에 대한 참조를 업데이트해야했습니다.


프로젝트를 정리하거나 Eclipse를 다시 시작해야합니다.


내가 한 건 더 있어요 올바른 프로젝트 경로를 제공하고 이클립스로 가져 오십시오.

그런 다음 프로젝트-> 정리-> 모든 프로젝트 정리로 이동하십시오.


클래스 경로에있는 라이브러리 파일의 일부 클래스가 다른 jar 파일에있을 수있는 존재하지 않는 클래스를 참조하는 경우이 오류가 표시됩니다. 내가 추가하지 않은 경우 여기,이 오류가 발생 org.springframework.beans-3.1.2.RELEASE.jar하고로부터 클래스를 확장했다 org.springframework.jdbc.core.support.JdbcDaoSupport이었다, org.springframework.jdbc-3.1.2.RELEASE.jar나의 클래스 패스를.


문제는 잘못된 병을 포함했을 수 있습니다. 나는 같은 문제가 있었고 그 이유는 프로젝트의 빌드 경로에 잘못된 기본 JRE 라이브러리를 포함했기 때문입니다. 다른 버전의 Java를 설치했으며 다른 버전의 Java의 JRE 파일을 포함하고있었습니다. (내 시스템에 JRE 1.6을 설치했고 이전에 설치된 Java로 인해 JRE 라이브러리 1.7이 빌드 경로에 포함되어있었습니다.) 빌드 경로에 포함 된 JRE 라이브러리가 올바른 버전인지 확인할 수 있습니다. 시스템에 설치 한 Java 버전


Eclipse Juno 에서이 문제가 발생했습니다. 근본 원인은 일부 스프링 항아리가 일시적인 maven 종속성에 의해 포함되었지만 잘못된 버전에 포함되었다는 것입니다.

따라서 모든 모듈 (또는 최소한 가장 중요한 코어, Bean, 컨텍스트, aop, tx 등)이 동일한 버전인지 봄으로 모듈 식 프레임 워크를 사용하는지 확인해야합니다.

문제를 해결하기 위해 잘못된 버전의 일시적 종속성을 피하기 위해 maven 의존성 제외를 사용했습니다.


나에게 문제는 잘못된 수입 때문이었습니다. 실제로 v7 지원 라이브러리를 추가 한 후 가져 오기를 업데이트해야합니다.

프로젝트의 각 클래스에 대해 다음과 같이 수행하여 수정할 수 있습니다 .

  1. import android.[*]각 클래스 에서을 사용하여 모든 행을 삭제하십시오.
  2. 가져 오기 재구성 : 상황에 맞는 메뉴에서 소스 / 조직 가져 오기 또는 (CTRL + SHIFT + O)를 선택하십시오.
  3. 프롬프트가 표시되면 라이브러리를 선택하십시오 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


I had the same exact problem marker and solved it by removing the @Override annotation from a method that was in fact the first implementation (the "super" one being an abstract method) and not an override.


In my case, the import references in many of the classes contained an extra word. I solved it by editing all the files to have the correct imports. I started doing the edits manually. But when I saw the pattern, I automated it with a find..replace in eclipse. This resolved the error.


Error : the hierarchy of the type "class name" is inconsistent error.

solution : class OtherDepJar {} --> is inside "other.dep.jar" .

class DepJar extends OtherDepJar {} --> is inside "dep.jar".

class ProblematicClass extends DepJar {} --> is inside current project .

If dep.jar is in the project's classpath, but other.dep.jar isn't in the project's classpath, Eclipse will show the" The hierarchy of the type ... is inconsistent error"


For me it was changing the Android API level to one with Google APIs


I was having this problem too... I found out that the hierarchy of the class that was throwing this exception, cannot be traced all way back to its root class by eclipse... I Explain:

In my case, I have 3 java project: A, B and C... where A and B are maven projects and C a regular java eclipse project...

In the project A, i have the interface "interfaceA" ... In the project B, i have the interface "interfaceB" that extends "interfaceA" In the project C, i have the concrete class "classC" that implements "interfaceB"

The "project C" was including the "project B" in its build path but not "project A" (so that was the cause of the error).... After including "project A" inside the build path of "C", everything went back to normal...


I had a class that extends LabelProvider in a project with OSGi, there the error occured. The solution was: Adding org.eclipse.jface to the required plugins in the manifest.mf instead of importing the single packages like org.eclipse.jface.viewers


if you are importing the eclipse project just 1. Go to the java build path setting under the project properties. 2. In case the JRE System library has an error sign attach to it double click it to open the Edit library window 3. Change the execution environment to the correct java version of the system or choose edit the other settings by checking the radio buttons assign to them. 4. Click finish


When importing a GWT project in Eclipse without installing "Google Plugin for Eclipse", this will occur. After installing "Google Plugin for Eclipse", this error will disappear.


Right click on the project folder and select "Java Build Path". Under "Java Build Path" you should be able to see libraries. Eclipse will show errors in any of those libraries. Fixing those issue will help to resolve the issue.


I had this error after doing some git merge from a branch where my classes extended a new interface. It was enough to Refresh (F5) the File-Tree in the Package Explorer frame of Eclipse.

It seems that Eclipse did not update everything properly and so the classes were extending a non-existing-yet interface. After refresh, all errors disappeared.


I had to switch from Eclipse Oxygen that I got from IBM and used IBM JDK 8 to Eclipse Photon and Oracle JDK 8. I'm working on Java customizations for .

참고URL : https://stackoverflow.com/questions/8520090/eclipse-compilation-error-the-hierarchy-of-the-type-class-name-is-inconsisten

반응형