简体   繁体   English

在Tomcat7上创建REST服务的依赖关系(带有Maven的Netbeans项目)

[英]Which dependencies to create REST services on Tomcat7 (Netbeans project with Maven)

My webapp includes REST web services and is running on GlassFish 3.1.2. 我的webapp包含REST Web服务,并且在GlassFish 3.1.2上运行。

I would like to run this app on Tomcat 7 instead of GlassFish. 我想在Tomcat 7而不是GlassFish上运行此应用程序。 What dependencies should I add and remove to enable REST services on Tomcat? 我应该添加和删除哪些依赖项才能在Tomcat上启用REST服务?

(At the moment I just changed "GlassFish" to "Tomcat" in the "Run" menu of Netbeans, but my http requests give a 404.) (目前,我只是在Netbeans的“运行”菜单中将“ GlassFish”更改为“ Tomcat”,但是我的http请求给出了404。)

Note: this is a Maven project on Netbeans. 注意:这是Netbeans上的Maven项目。

Ok here is the list of dependencies you may need. 好的,这是您可能需要的依赖项列表。 Please note I just put latest version but you may want to use a different version. 请注意,我只是输入了最新版本,但您可能要使用其他版本。 Please also check for compatibility of these versions with each other. 请同时检查这些版本之间的兼容性。

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

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0</version>
</dependency>

Needed if you are using jackson to parse json 如果您使用杰克逊解析json,则需要

<dependency>
    <groupId>com.fasterxml.jackson.jaxrs</groupId>
    <artifactId>jackson-jaxrs-json-provider</artifactId>
    <version>2.3.3</version>
</dependency>

This is what I am using on my tomcat but little bit older versions 这是我在雄猫上使用的,但版本较旧

Now about your 404 现在介绍您的404
First check if the dependencies fix your problem. 首先检查依赖性是否可以解决您的问题。 404 may be an issue from some thing not configured right in your web.xml as well. 404可能是由于您的web.xml中未正确配置的某些问题所致。

I hope it helps you solve your problem :) 我希望它可以帮助您解决问题:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM