mavan 配置tomcat8-maven-plugin插件 ,创建war运行中的项目问题

在练习创建maven project项目,创建war类型时,由于本地jdk是1.8的,要求使用的tomcat至少也是8.0的,tomcat7.0的无法只用,maven的pom.xml只能使用tomcat7-maven-plugin

配置如下

  
	org.apache.tomcat.maven  
	tomcat7-maven-plugin  
	2.2  
	
	80
	/
	
 

 在Maven的中央仓库中没有找到tomcat8-maven-plugin的plugin

在https://mvnrepository.com/这个网址也没有找到

后来通过在网上百度找到下面这个方法

就是使用Maven中的 ,是用来配置插件地址的,因为maven的所有功能都是使用插件来实现功能的,因此需要从特定的地址下载插件包。

参考https://blog.csdn.net/wxh_xdk/article/details/79756768

在pom.xml文件中配置如下


  	
  		  
		  org.apache.tomcat.maven  
		  tomcat8-maven-plugin  
		  3.0-r1655215  
		  
		  	80
		  	/
		  
		  
  	
  
  
	 
	  
	    alfresco-public
	    https://artifacts.alfresco.com/nexus/content/groups/public
	  
	  
	    alfresco-public-snapshots
	    https://artifacts.alfresco.com/nexus/content/groups/public-snapshots
	    
	      true
	      daily
	    
	  
	  
	    beardedgeeks-releases
	    http://beardedgeeks.googlecode.com/svn/repository/releases
	  
	  

 

这样就能使用tomcat8-maven-plugin插件了。 

 

 

在配置好tomcat8-maven-plugin插件后,启动tomcat项目的时候一直报下面这个错误

java.lang.LinkageError

严重: Servlet.service() for servlet [jsp] in context with path [] threw exception [java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(Ljavax/servlet/ServletConfig;)Lorg/apache/tomcat/InstanceManager;" the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/index_jsp, and the class loader (instance of org/codehaus/plexus/classworlds/realm/ClassRealm) for the method's defining class, org/apache/jasper/runtime/InstanceManagerFactory, have different Class objects for the type org/apache/tomcat/InstanceManager used in the signature] with root cause
java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(Ljavax/servlet/ServletConfig;)Lorg/apache/tomcat/InstanceManager;" the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/index_jsp, and the class loader (instance of org/codehaus/plexus/classworlds/realm/ClassRealm) for the method's defining class, org/apache/jasper/runtime/InstanceManagerFactory, have different Class objects for the type org/apache/tomcat/InstanceManager used in the signature
	at org.apache.jsp.index_jsp._jspInit(index_jsp.java:32)
	at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:49)
	at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:180)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1081)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
	at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

 通过网上查找,发现只需要在启动项目的时候将原先的 clean tomcat8:run 换成 clean tomcat8:run-war 运行就可以了

修改前

mavan 配置tomcat8-maven-plugin插件 ,创建war运行中的项目问题_第1张图片

修改后

mavan 配置tomcat8-maven-plugin插件 ,创建war运行中的项目问题_第2张图片

换成 clean tomcat8:run-war 就可以正常运行了

 

你可能感兴趣的:(maven,插件,tomcat,maven,plugin)