Idea开发环境 maven项目在tomcat里运行

Intellij IDEA使用教程相关系列 目录

tomcat运行

步骤1:在pom.xml里添加插件代码

                        
				org.apache.tomcat.maven
				tomcat7-maven-plugin
				2.0
				
					8080
					UTF-8
					/bdcrpc
					tomcat
				
			

步骤2:点击刷新插件效果,在plugins里会出现tomcat插件

Idea开发环境 maven项目在tomcat里运行_第1张图片

Idea开发环境 maven项目在tomcat里运行_第2张图片

选择tomcat7-run运行

Idea开发环境 maven项目在tomcat里运行_第3张图片

可以选择是正常运行和debug模式运行,右键tomcat7:run

Idea开发环境 maven项目在tomcat里运行_第4张图片

启动成功。

Idea开发环境 maven项目在tomcat里运行_第5张图片

 

异常处理 

异常1:

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/bdcrpc]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    ... 6 more
Caused by: java.lang.ClassCastException: org.springframework.web.SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer
    at org.apache.catalina.startup.ContextConfig.getServletContainerInitializer(ContextConfig.java:1657)
    at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1565)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1273)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
    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:5173)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more

一月 22, 2019 5:55:39 下午 org.apache.catalina.core.ContainerBase startInternal
严重: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
出现原因:tomcat插件和项目引用的jar冲突。都有包含tomcat-servlet-api.jar

解决方案:pom引用tomcat-servlet-api,添加scope,如下


			org.apache.tomcat
			tomcat-servlet-api
			7.0.64
			provided

 

你可能感兴趣的:(IDEA,Intellij,IDEA教程)