使用maven启动tomcat时出现以下错误
java.util.concurrent.ExecutionException:org.apache.catalina.LifecycleException:无法启动组件 [StandardEngine [卡塔利娜] .StandardHost [本地主机] .StandardContext [/ web_store]] 在java.util.concurrent.FutureTask.report(未知来源)at java.util.concurrent.FutureTask.get(未知来源)
引起:org.apache.catalina.LifecycleException:无法启动 零件 [StandardEngine [卡塔利娜] .StandardHost [本地主机] .StandardContext [/ web_store]] 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153) ......还有6个
引起:java.lang.IllegalArgumentException:Servlet映射 指定一个未知的servlet名称dispatcherServlet-servlet at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3180) 在 org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3159) 在 org.apache.catalina.startup.ContextConfig.configureContext(ContextConfig.java:1376)
2016年8月10日下午2:28:01 org.apache.catalina.core.ContainerBase startInternal SEVERE:启动时子容器失败 java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException:无法启动组件 [StandardEngine [Catalina] .StandardHost [localhost]] at java.util.concurrent.FutureTask.report(未知来源)at java.util.concurrent.FutureTask.get(未知来源)
我正在使用maven并收到错误 虽然启动tomcat正常运行,但是当我使用tomcat运行项目时,它显示以下错误
修改
1 web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>webstore</display-name>
<welcome-file-list>
<welcome-file>view/index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcherServlet-servlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
2 dispatcherServlet-servlet.xml
<mvc:annotation-driven />
<context:component-scan base-package="web_store.*" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/view/" />
<property name="suffix" value=".jsp" />
</bean>
答案 0 :(得分:1)
你的错误在这里:
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcherServlet-servlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
在servlet映射中,您需要引用已在web.xml
中定义的servlet,此处仅定义了dispatcherServlet
,因此只需将dispatcherServlet-servlet
重命名为dispatcherServlet
在你的servlet映射中作为下一个:
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>