Java HTTP状态404–;找不到

Java HTTP状态404–;找不到,java,rest,tomcat,Java,Rest,Tomcat,请求后http://localhost:8080/example/rest/hello/message我收到错误“HTTP状态404–未找到”。有什么问题?我使用Tomcat8。提前谢谢 App.java: @ApplicationPath("/rest") public class App extends Application{ } Service.java @Path("/hello") public class Service { @GET @Path("/message") pub

请求后<代码>http://localhost:8080/example/rest/hello/message我收到错误“HTTP状态404–未找到”。有什么问题?我使用Tomcat8。提前谢谢

App.java:

@ApplicationPath("/rest")
public class App extends Application{
}
Service.java

@Path("/hello")
public class Service {

@GET
@Path("/message")
public String getMessage() {

    String message = "Welcome";
    return message;

   }
}
pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>example</groupId>
<artifactId>example</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <spring.version>4.3.8.RELEASE</spring.version>
</properties>

<dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.bundles</groupId>
        <artifactId>jaxrs-ri</artifactId>
        <version>2.13</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet</artifactId>
        <version>2.13</version>
    </dependency>
</dependencies>

4.0.0
例子
例子
1.0-快照
4.3.8.1发布
javax.servlet
javax.servlet-api
3.1.0
org.springframework
spring上下文
${spring.version}
org.springframework
spring上下文支持
${spring.version}
org.springframework
德克萨斯州春季
${spring.version}
org.springframework
SpringJDBC
${spring.version}
org.glassfish.jersey.bundles
杰克斯里
2.13
org.glassfish.jersey.containers
jersey容器servlet
2.13

Web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
     version="3.1">

</web-app>


我看到您的服务器路径不包括
示例
,请尝试:
http://localhost:8080/rest/hello/message
结果是一样的。你能给我看一下描述中的
web.xml
文件吗?更改这一行
@ApplicationPath(“/rest”)
@ApplicationPath(“rest”)
,如果
示例
是您的项目名称,请尝试使用以前的路径。