IDEA使用mave-tomcat7插件启动报ClassFormatException

 Unable to process Jar entry [META-INF/versions/9/module-info.class] from Jar [jar:file:/D:/localRepository2/org/apache/logging/log4j/log4j-api/2.11.1/log4j-api-2.11.1.jar!/] for annotations
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19
	at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:133)
	at org.apache.tomcat.util.bcel.classfile.ConstantPool.<init>(ConstantPool.java:60)
	at org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:209)
	at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:119)
	at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2134)
	at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:2010)
	at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1976)
	at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1961)
	at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1319)
	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:376)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

经过在网上查找资料发现是log4j的版本太高了。项目中使用maven-tomcat7-plugins来进行启动。
然后把log4j的版本改成2.9就没有报错了。

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.9.0</version>
</dependency>
### 回答1: Maven使用Tomcat8-maven-plugin插件可以将Web应用程序部署到Tomcat服务器上。以下是使用Tomcat8-maven-plugin插件的步骤: 1. 在pom.xml文件中添加以下插件配置: ``` <build> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat8-maven-plugin</artifactId> <version>3.0-r1756463</version> <configuration> <url>http://localhost:8080/manager/text</url> <username>admin</username> <password>admin</password> <path>/myapp</path> </configuration> </plugin> </plugins> </build> ``` 2. 配置Tomcat服务器的管理用户和密码,以便插件可以将应用程序部署到服务器上。在Tomcat的conf/tomcat-users.xml文件中添加以下内容: ``` <role rolename="manager-gui"/> <user username="admin" password="admin" roles="manager-gui"/> ``` 3. 在命令行中执行以下命令将应用程序部署到Tomcat服务器上: ``` mvn tomcat8:deploy ``` 4. 如果需要重新部署应用程序,可以执行以下命令: ``` mvn tomcat8:redeploy ``` 5. 如果需要从Tomcat服务器中卸载应用程序,可以执行以下命令: ``` mvn tomcat8:undeploy ``` 以上就是使用Tomcat8-maven-plugin插件的基本步骤。需要注意的是,插件的版本号和Tomcat服务器的版本号需要匹配,否则可能会出现兼容性问题。 ### 回答2: Maven是一种基于Java平台的自动化构建工具,可以管理项目的依赖关系、编译、测试以及部署。Tomcat8-maven-plugin则是Maven插件的一种,用于将Maven项目打包成Web应用并且在Tomcat容器中运行。 Tomcat8-maven-plugin插件使用方法如下: 1.在Maven项目的pom.xml文件中,添加如下插件配置: ``` <build> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat8-maven-plugin</artifactId> <version>X.X.X</version> <configuration> <url>http://localhost:8080/manager/text</url> <server>TomcatServer</server> <path>/hello</path> </configuration> </plugin> </plugins> </build> ``` 其中,groupId和artifactId表示Tomcat8-maven-plugin插件的组ID和插件ID,version表示插件的版本号。configuration标签中的三个元素分别表示Tomcat管理页面的URL、Maven的服务器配置、Web应用在Tomcat容器中的访问路径。 2.运行Maven命令,将项目打包成war包: ``` mvn package ``` 3.将war包上传到Tomcat服务器,并在Tomcat管理页面上部署Web应用。 4.在Maven项目的根目录下,运行如下命令启动Tomcat容器: ``` mvn tomcat8:run ``` 5.在浏览器中输入http://localhost:8080/hello,即可访问Web应用。 总的来说,使用Tomcat8-maven-plugin插件能够简化项目的部署和运行,并且可以通过配置实现一些定制化的需求,适合于中小型Java Web项目的开发和维护。 ### 回答3: Maven是一个Java项目管理和构建工具,能够自动下载所需的依赖包、自动编译、测试和打包等,方便开发人员进行软件项目的快速开发。 Tomcat8-maven-plugin是一个Maven的插件,它可用于将Web应用程序部署到Tomcat容器中。它能够快捷地将Web应用程序打包并部署到Tomcat 8服务器中,无需手动将WAR文件复制到Tomcat的webapps目录中。 它提供了许多配置选项,例如上下文路径、端口等参数,可以根据需要定制化自己的应用程序配置,使得部署更加灵活和方便。 使用Tomcat8-maven-plugin插件的步骤如下: 1. 在pom.xml文件中添加Tomcat8-maven-plugin配置 ```xml <build> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat8-maven-plugin</artifactId> <version>3.0-r1756466</version> <configuration> <url>http://localhost:8080/manager/text</url> <server>tomcat8</server> <path>/myApp</path> </configuration> </plugin> </plugins> </build> ``` 2. 运行 Maven Build ``` mvn clean install ``` 以上是Tomcat8-maven-plugin插件的基本配置和使用方法,通过它能够简单高效地实现Web应用程序的部署和管理,方便开发人员进行项目开发和测试。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值