Created
January 16, 2016 17:58
-
-
Save kazurof/feec235108ad69cb205f to your computer and use it in GitHub Desktop.
最小構成のJAX-RS サンプル ref: http://qiita.com/kazurof/items/cec5fcd24c3e3ece544d
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 org.example; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.Produces; | |
import javax.ws.rs.core.MediaType; | |
@Path("/sample") | |
public class EndPoint { | |
@GET | |
@Produces(MediaType.TEXT_PLAIN) | |
public String start() { | |
System.out.println("access."); | |
return "executed."; | |
} | |
} | |
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
│ pom.xml | |
│ | |
└─src | |
└─main | |
├─java | |
│ └─org | |
│ └─example | |
│ EndPoint.java | |
│ | |
└─webapp | |
└─WEB-INF | |
web.xml |
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
<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>org.example</groupId> | |
<artifactId>minimum-jax-rs</artifactId> | |
<version>0.0.1</version> | |
<packaging>war</packaging> | |
<dependencies> | |
<dependency> | |
<groupId>org.glassfish.jersey.containers</groupId> | |
<artifactId>jersey-container-servlet</artifactId> | |
<version>2.22.1</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.3</version> | |
<configuration> | |
<source>1.8</source> | |
<target>1.8</target> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" | |
version="3.1"> | |
<servlet> | |
<servlet-name>Jersey Web Application</servlet-name> | |
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> | |
<init-param> | |
<param-name>jersey.config.server.provider.packages</param-name> | |
<param-value>org.example</param-value> | |
</init-param> | |
</servlet> | |
<servlet-mapping> | |
<servlet-name>Jersey Web Application</servlet-name> | |
<url-pattern>/api/*</url-pattern> | |
</servlet-mapping> | |
</web-app> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment