这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos
mvn "io.quarkus:quarkus-maven-plugin:create" \
-DprojectGroupId="com.bolingcavalry" \
-DprojectArtifactId="hello-quarkus" \
-DprojectVersion="1.0-SNAPSHOT" \
-DclassName="HobbyResource" \
-Dpath="actions"
package com.bolingcavalry;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.time.LocalDateTime;
@Path("/actions")
public class HobbyResource {
@ConfigProperty(name = "greeting.message")
String message;
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "Hello RESTEasy, " + LocalDateTime.now() + " [" + message + "]";
}
}
mvn clean package -U -DskipTests -Dquarkus.package.type=uber-jar
java -Dgreeting.message="from system properties" -jar hello-quarkus-1.0-SNAPSHOT-runner.jar
export GREETING_MESSAGE="from Environment variables"
GREETING_MESSAGE=from .env file
greeting.message=from config/application.properties
greeting.name=Will
greeting.message=hello, ${greeting.name:xxxxxx}
greeting.message=hello, ${quarkus.uuid}
my.collection=dog,cat,turtle
@Path("/actions")
public class HobbyResource {
@ConfigProperty(name = "my.collection")
List<String> message;
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "Hello RESTEasy, " + LocalDateTime.now() + ", " + message + "";
}
}
my.collection[0]=dog
my.collection[1]=cat,turtle
my.collection[2]=turtle