ресурс запроса сервера jersey недоступен - ошибка 404 - PullRequest
0 голосов
/ 16 июня 2020

Я использую Jersey 2.7 для создания остальных веб-сервисов. Вот связанный файл pom. xml:

        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-server</artifactId>
            <version>2.27</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet</artifactId>
            <version>2.27</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.inject</groupId>
            <artifactId>jersey-hk2</artifactId>
            <version>2.27</version>
        </dependency>

И класс приложения:

@ApplicationPath("rest")
public class Application extends ResourceConfig {
    public Application() {
        this.packages("com.my.packge");
    }
}

И класс api:

@Path("/api")
public class myApi {

    @GET
    @Consumes(MediaType.TEXT_PLAIN)
    @Path("/test")
    public String test(){
        return "I'm here!";
    }
}

Я использую tomcat для запустите программу и вот результат:

Message The requested resource [/rest/api/test2] is not available

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...