mvn io.quarkus:quarkus-maven-plugin:1.5.2.Final:create
mvn quarkus:dev
@GET
@Path("/fr")
@Produces(MediaType.TEXT_PLAIN)
public String bonjour() {
return "hello";
}
Try out your new endpoint : curl localhost:8080/hello/fr
Add in your Resource class:
@ConfigProperty(name = "greeting")
String greeting;
Add in your application.properties
:
greeting=Hola
Try to change the value of the property and try again.
Let's start by adding the needed extensions :
mvn quarkus:add-extension -Dextension="quarkus-resteasy-jsonb, quarkus-jdbc-h2, quarkus-hibernate-orm-panache"
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:default
quarkus.hibernate-orm.database.generation=drop-and-create
package org.sebi;
import javax.persistence.Entity;
import io.quarkus.hibernate.orm.panache.PanacheEntity;
@Entity
public class Task extends PanacheEntity {
public String name;
public boolean done;
}
package org.sebi;
import java.util.List;
import javax.transaction.Transactional;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
@Path("/tasks")
public class TaskResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Task> tasks(){
return Task.listAll();
}
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Transactional
public Response createTask(Task task){
task.persist();
return Response.status(Status.CREATED).entity(task).build();
}
}