Last active
March 15, 2019 01:38
-
-
Save giosakti/01fb19120be632871e8b to your computer and use it in GitHub Desktop.
gradle-jersey-jetty-sample
This file contains hidden or 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 com.starqle.hcm; | |
import com.sun.jersey.spi.container.servlet.ServletContainer; | |
import org.eclipse.jetty.server.Server; | |
import org.eclipse.jetty.servlet.ServletContextHandler; | |
import org.eclipse.jetty.servlet.ServletHolder; | |
public class Application { | |
public static void main (String[] args) throws Exception { | |
ServletHolder sh = new ServletHolder(ServletContainer.class); | |
sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.PackagesResourceConfig"); | |
sh.setInitParameter("com.sun.jersey.config.property.packages", "com.starqle.hcm"); | |
sh.setInitParameter("com.sun.jersey.api.json.POJOMappingFeature", "true"); | |
Server server = new Server(8080); | |
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); | |
server.setHandler(context); | |
context.addServlet(sh, "/*"); | |
server.start(); | |
server.join(); | |
} | |
} |
This file contains hidden or 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
apply plugin: 'java' | |
apply plugin: 'idea' | |
apply plugin: 'jetty' | |
sourceCompatibility = 1.5 | |
version = '1.0' | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
testCompile group: 'junit', name: 'junit', version: '4.11' | |
testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3' | |
testCompile group: 'com.sun.jersey', name: 'jersey-client', version: '1.18.2' | |
compile group: 'com.sun.jersey', name: 'jersey-core', version: '1.18.2' | |
compile group: 'com.sun.jersey', name: 'jersey-server', version: '1.18.2' | |
compile group: 'com.sun.jersey', name: 'jersey-servlet', version: '1.18.2' | |
compile group: 'org.eclipse.jetty', name: 'jetty-server', version: '9.2.4.v20141103' | |
compile group: 'org.eclipse.jetty', name: 'jetty-servlet', version: '9.2.4.v20141103' | |
} |
This file contains hidden or 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 com.starqle.hcm; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.Produces; | |
import javax.ws.rs.core.MediaType; | |
@Path("myresource") | |
public class MyResource { | |
@GET | |
@Path("getIt") | |
@Produces(MediaType.TEXT_PLAIN) | |
public String getIt() { | |
return "Get it!"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
would not like to offend you by my comment but I don't know the directory structure that could be used for building your code up to being deployable ... if you can give a GitHub link to the project ( with the gists already structured ) then maybe it would be more useful for me and helpful for me.