Skip to content

Instantly share code, notes, and snippets.

@pdurbin
Last active December 29, 2015 09:49
Show Gist options
  • Save pdurbin/7652999 to your computer and use it in GitHub Desktop.
Save pdurbin/7652999 to your computer and use it in GitHub Desktop.
(Slightly tweaked) code from watching Hello JavaEE 7 With Maven 3, JAX-RS 2.0 and JSON ...In 3 Mins : Adam Bien's Weblog - http://www.adam-bien.com/roller/abien/entry/hello_javaee_7_with_maven
package com.greptilian.json;
import javax.json.Json;
import javax.json.JsonObject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@Path("greetings")
public class GreetingsResource {
@GET
public JsonObject greetings() {
return Json.createObjectBuilder().add("hello", "world").build();
}
}
<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>com.greptilian</groupId>
<artifactId>json</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
</project>
package com.greptilian.json;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("resources")
public class RESTConfiguration extends Application {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment