[英]tomcat 8.0 failed to start while running a simple jersey program in eclipse
我对这个问题感到沮丧。 尝试了Internet上所有可能的解决方案,但仍然没有运气。
当我运行此代码时,tomcat每次都无法启动并失败。 请帮忙
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- This web.xml file is not required when using Servlet 3.0 container,
see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html#d4e194 -->
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.restapp.jerseyapp</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/jersey/*</url-pattern>
</servlet-mapping>
</web-app>
码:
package com.restapp.jerseyapp;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
/** Example resource class hosted at the URI path "/myresource"
*/
@Path("/hi")
public class MyResource {
/** Method processing HTTP GET requests, producing "text/plain" MIME media
* type.
* @return String that will be send back as a response of type "text/plain".
*/
@GET
@Produces("text/plain")
public String getIt() {
return "Hi there!";
}
}
控制台输出
INFO: Starting Servlet Engine: Apache Tomcat/8.0.47
Oct 09, 2017 8:20:51 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/jerseyapp]]
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
我也有同样的问题。 我通过从本地Maven存储库中删除球衣罐,然后重新安装了相同的罐来解决此问题。
C:\Users\{user}\.m2\repository\com\sun\jersey
完成上述步骤后,请执行maven install。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.