无法成功运行maven + servlet 3.0 + jax-rs 2.0应用程序

时间:2015-02-24 04:19:23

标签: jax-rs

我一直关注互联网上的各种资源,但似乎无法使用maven + servlet 3.x + jax-rs 2.x获得一个简单的hello world应用程序

这是我的Appconfig:

@ApplicationPath("corp")
public class AppConfig extends ResourceConfig{  
    public AppConfig(){
        System.out.println("This Class Is Initializing");
        packages("com.sk176h.corporate.pages");
    }
}

和我简单的资源:

@Path("home")
public class Home {
    @GET
    @Path("/")
    @Produces(MediaType.TEXT_HTML)
    public String get(){
        return "<html><body>hello</body></html>";
    }
}

我在maven

中定义了以下依赖项
<dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <version>2.16</version>
        </dependency>

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

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-server</artifactId>
            <version>2.0-m13-2</version>
            <scope>provided</scope>
        </dependency>

我的根上下文是/ corporate

当我从eclipse启动apache服务器时,我可以成功点击/公司

然而/ corporate / corp / home会抛出标准的apace资源未找到错误

我做得不好?

enter image description here

0 个答案:

没有答案