【问题标题】:simple example using resteasy-jaxrs not working使用 resteasy-jaxrs 的简单示例不起作用
【发布时间】:2019-03-19 07:44:24
【问题描述】:

当我访问该页面时,我无法收到“你好”的消息。

package jaxrs.ressources;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("greeting")
public class HelloRessource {
    @GET
    @Path("hello")
    @Produces(MediaType.TEXT_PLAIN)
    public String sayhello() {
    return "Hello from JAX-RS";
}}

还有这个类

package jaxrs.utilities;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("/rest")
public class RestActivator  extends Application{

}

网址http://127.0.0.1:8383/JAXRS_Hello_GL-1.0/rest/greeting/hello总是显示“未找到”

有什么解决办法吗?

这是包含 pom.xml 文件的内容:

    <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.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.esprit.jaxrs.hello</groupId>
  <artifactId>JAXRS_Hello_GL</artifactId>
  <version>1.0</version>
  <packaging>war</packaging>

  <properties>
    <failOnMissingWebXml>false</failOnMissingWebXml>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
  </properties>
  <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs -->
<dependencies>

<!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs -->
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jaxrs</artifactId>
    <version>3.1.4.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs -->
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>3.1.4.Final</version>
</dependency>

  </dependencies>

</project>

如果您需要其他说明,请告诉我

【问题讨论】:

  • 你从哪里得到JAXRS_Hello_GL-1.0
  • wildfly服务器日志中注册的web context的名称
  • 尝试添加this

标签: jax-rs resteasy


【解决方案1】:

你能添加初始化器吗:

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-servlet-initializer</artifactId>
    <version>3.1.4.Final</version>
</dependency>

Mr.Paul在cmets中有解决方法,请查收

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-01
    • 2015-11-23
    • 2016-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多