继承一个类的时候报错:The hierarchy of the type 'Class name' is inconsistent

来源:互联网 发布:手机投影画画软件 编辑:程序博客网 时间:2024/05/17 06:12

一、问题描述

在开发中,需要集成一个类的时候,发现继承的时候出现错误:The hierarchy of the type 'Class name' is inconsistent,大致意思是类的层次不匹配。


二、原因

因为所集成的类中依赖了其他的类,如ServletRequest,而该类或接口没有在项目中映入,所以会出现此错误。


三、解决办法

在pom.xml中加入支持包

<dependency>            <groupId>org.apache.tomcat</groupId>            <artifactId>tomcat-servlet-api</artifactId>            <version>7.0.8</version>            <scope>provided</scope></dependency>
注意scope的作用范围,在此只作为支持包就可以了。也可以不用写scope范围。


0 0
原创粉丝点击