Last active
January 14, 2017 08:25
-
-
Save lzhoucs/7037961 to your computer and use it in GitHub Desktop.
jax-rs with jersey 2.3 + tomcat 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eclipse JEE + tomcat 7 server(embedded in eclipse) | |
runtime jar required(for tomcat 7): | |
asm-all-repackaged-2.2.0-b14.jar | |
cglib-2.2.0-b14.jar | |
guava-14.0.1.jar | |
hk2-api-2.2.0-b14.jar | |
hk2-locator-2.2.0-b14.jar | |
hk2-utils-2.2.0-b14.jar | |
javax.annotation-api-1.2.jar | |
javax.inject-2.2.0-b14.jar | |
jaxb-api-2.2.7.jar(not sure) | |
validation-api-1.1.0.Final.jar | |
jersey-client.jar | |
jersey-common.jar | |
jersey-container-servlet-core.jar | |
jersey-container-servlet.jar | |
jersey-server.jar | |
javax.ws.rs-api-2.0.jar | |
url: | |
http://host:port/rest/service | |
this example doesn't include client side code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<servlet> | |
<servlet-name>REST Services</servlet-name> | |
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> | |
<init-param> | |
<param-name>jersey.config.server.provider.packages</param-name> | |
<param-value>foo.restful</param-value> | |
</init-param> | |
<load-on-startup>1</load-on-startup> | |
</servlet> | |
<servlet-mapping> | |
<servlet-name>REST Services</servlet-name> | |
<url-pattern>/rest/*</url-pattern> | |
</servlet-mapping> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo.restful; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.Produces; | |
import javax.ws.rs.core.MediaType; | |
/** | |
* A RESTFul Web Service that provides Endeca Workbench(WebStudio) | |
* Authentication service to internal apps(such as Merchtools) through HTTP. | |
* | |
* @author lzhoucs | |
* | |
*/ | |
@Path("service") | |
public class WSAuthService { | |
/** | |
* | |
* @return "true" for success, "false" otherwise | |
*/ | |
@GET | |
@Produces(MediaType.TEXT_PLAIN) | |
public String sayPlainTextHello() { | |
return "Hello Jersey"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Jersey Guide says you can you auto generation for create application with support jersey.