An example with Gradle and current libraries
RESTEasy is a cool project for building RESTful Web Services with Java. It is an JAX-RS
implementation. And I really like the tight integration into quarkus.
I show you how to build a simple project with Gradle (build.gradle.kts):
plugins { war id("org.gretty") version "3.0.1" } repositories { jcenter() } dependencies { implementation("org.jboss.resteasy:resteasy-jackson2-provider:4.4.2.Final") implementation("org.jboss.resteasy:resteasy-client:4.4.2.Final") providedCompile("javax.servlet:javax.servlet-api:4.0.1") testImplementation("org.junit.jupiter:junit-jupiter-api:5.5.1") testImplementation("org.junit.jupiter:junit-jupiter-api:5.5.1") // Use JUnit Jupiter Engine for testing. testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.5.1") } val test by tasks.getting(Test::class) { // Use junit platform for unit tests useJUnitPlatform() }
That’s everything you need for building the project.
And the REST Controller could look like this:
package de.claudioaltamura.resteasy.helloworld; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; @Path("/helloworld") public class HelloWorldResource { @GET @Produces("application/json") public HelloWorld greeting(@QueryParam("name") String name) { return new HelloWorld(name); } }
If you now interested to learn more RESTEasy, than you can go deeper and look at the links below or at my github project.
Links
RESTEasy Documentation
https://resteasy.github.io/docs/
MicroProfile REST Client
https://github.com/eclipse/microprofile-rest-client
Jakarta RESTful Web Services (JAX-RS)
https://github.com/eclipse-ee4j/jaxrs-api
RESTEasy HelloWorld example
https://github.com/claudioaltamura/resteasy-helloworld