Maven中使用tomcat:run出现错误org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException

转自https://blog.csdn.net/Franck_Lou/article/details/78352864

Maven中使用tomcat:run出现错误org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException

这几天在学习maven,跟着视频上学maven,看到人家直接tomcat:run就成功部署了项目,所以自己也尝试了一下,但是项目可以正常部署,但是访问的时候servlet访问正常。jsp访问出现编译错误。


1.使用maven:tomcat发布项目成功。 
这里写图片描述

2.servlet访问一切正常。jsp访问出现org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException的错误

这里写图片描述

这里写图片描述

3.查看编译路径下没有对应的.class文件

这里写图片描述

分析原因: 
1.pom.xml文件是正常,编译不存在jar包冲突

这里写图片描述

2.配置是正常的。查阅资料以后说是jdk版本什么的问题。多方修改没有任何改观。 
换一个思路去查询tomcat:run怎么运行。原来适合maven整合因此可以得知在pom文件中加入插件所以在pom.xml文件中加入如下配置

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <port>9999</port> 
                <uriEncoding>UTF-8</uriEncoding>
            </configuration>
        </plugin>
    </plugins>
</build>

这里的port可以自定义端口不在和其它8080端口冲突 
这时当你再次使用tomcat:run的时候发现还是和刚才一样。是因为他还是沿用了上一次的tomcat插件(默认是6)所以运行的时候使用 tomcat7:run

这里写图片描述

这样配置生效,通过地址去访问 
效果如下: 
这里写图片描述

这里写图片描述

猜你喜欢

转载自blog.csdn.net/h985161183/article/details/82221307