配置tomcat插件,一直报错,自己一点儿一点儿排错,一点儿一点儿,心态都要奔溃了,搜索了很多的教程都不行,花了3 4个小时,终于可以了,下面是错误信息,还有另一个但是我没来的及复制另一个错误信息,抱歉。
错误信息:
严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>common-tomcat-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</build>
<!-- https://mvnrepository.com/artifact/org.apache.tomcat.maven/tomcat-maven-plugin-it -->
<dependency>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat-maven-plugin-it</artifactId>
<version>2.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</dependency>
以上只是搜索中发现解决问题的几种办法,但是对我的问题好像都不适用。如果你也是这样的话 不如试试下面这一种,我的就是通过以下的方法解决了
<build>
<plugins>
<!--配置tomcat插件-->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<!--添加version字段,告诉idea插件的版本号,防止idea找不到对应插件报错-->
<version>2.2</version>
<configuration>
<path>/</path>
<port>9090</port>
<uriEncoding>UTF-8</uriEncoding>
<!--添加忽略war包检查标签,则可以让tomcat7:run指令正常启动tomcat-->
<ignorePackaging>true</ignorePackaging>
</configuration>
</plugin>
</plugins>
</build>
博主在配置Tomcat插件时遇到持续报错,经过34小时排查,最终找到解决方案。错误涉及ClassNotFoundException,尤其是Spring的ContextLoaderListener。尝试过多种网上教程未果,最后成功的关键在于添加了'tomcat7-maven-plugin',并配置了version、path、port、uriEncoding和ignorePackaging等参数。
568

被折叠的 条评论
为什么被折叠?



