【发布时间】:2023-02-14 20:40:27
【问题描述】:
我在这里最简单的代码中遇到问题:
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@Path("/test")
public class HelloResource {
@GET
public String sayHello(){
return "hello";
}
}
应用:
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
@ApplicationPath("/api")
public class MyApplication extends Application {
}
pom:
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-web-api</artifactId>
<version>9.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.5.0</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.5.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.1.2.Final</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
我点击链接:http://localhost:8080/name_war/api/test
这给我:
Http 状态 404:请求的资源 [/javaEE_1_0_SNAPSHOT_war/api/test] 不可用
【问题讨论】: