Last active
July 8, 2019 17:52
-
-
Save yauhen-info/7adc9efd94b8b3774ea8 to your computer and use it in GitHub Desktop.
Maven, Jersey, Tomcat Embedded sample
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
Also can be helpful following links: | |
https://devcenter.heroku.com/articles/create-a-java-web-application-using-embedded-tomcat | |
http://chiaboy.wordpress.com/2014/07/20/simple-jersey-example-with-intellij-idea-and-tomcat | |
http://www.daedtech.com/faking-tomcat-support-in-intellij-idea-community-version |
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 info.yauhen.webapp; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.PathParam; | |
import javax.ws.rs.core.Response; | |
@Path("/hello") | |
public class MainResource { | |
@GET | |
@Path("/{param}") | |
public Response getMessage(@PathParam("param") String message) { | |
String output = "It works: " + message; | |
return Response.status(200).entity(output).build(); | |
} | |
} |
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/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>info.yauhen</groupId> | |
<artifactId>repost</artifactId> | |
<packaging>war</packaging> | |
<version>1.0-SNAPSHOT</version> | |
<name>repost Maven Webapp</name> | |
<url>http://maven.apache.org</url> | |
<dependencies> | |
<dependency> | |
<groupId>org.glassfish.jersey.containers</groupId> | |
<artifactId>jersey-container-servlet</artifactId> | |
<version>2.10.1</version> | |
</dependency> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>3.8.1</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
<build> | |
<finalName>repost</finalName> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.tomcat.maven</groupId> | |
<artifactId>tomcat7-maven-plugin</artifactId> | |
<version>2.2</version> | |
<configuration> | |
<server>TomcatServer</server> | |
<path>/repost</path> | |
</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
<!DOCTYPE web-app PUBLIC | |
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" | |
"http://java.sun.com/dtd/web-app_2_3.dtd" > | |
<web-app> | |
<display-name>Archetype Created Web Application</display-name> | |
<servlet> | |
<servlet-name>jersey-servlet</servlet-name> | |
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> | |
<init-param> | |
<param-name>jersey.config.server.provider.packages</param-name> | |
<param-value>info.yauhen.webapp</param-value> | |
<load-on-startup>1</load-on-startup> | |
</init-param> | |
</servlet> | |
<servlet-mapping> | |
<servlet-name>jersey-servlet</servlet-name> | |
<url-pattern>/rest/*</url-pattern> | |
</servlet-mapping> | |
</web-app> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment