将本地的改动极速同步到远程服务端,并自动生效,掌握此技能,开发调试会更高效
这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos
就是下图这样:
以上是常见的处理问题手段,如果咱们的代码是quarkus应用,也能这样远程调试吗?
答案是可以,接下来咱们一起实战如何远程调试quarkus应用
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 message + ", Hello RESTEasy " + LocalDateTime.now();
}
}
复制
# 这是一个自定义属性,在业务代码中使用ConfigProperty注解取得其值 greeting.message=message from configuration # 远程调试时用到的参数,可变jar,也就是支持热部署的jar quarkus.package.type=mutable-jar # 远程调试时用到的参数,为了安全起见,需要指定密码 quarkus.live-reload.password=changeit
复制
mvn clean package -U -DskipTests
复制
docker build \ -f src/main/docker/Dockerfile.jvm \ -t bolingcavalry/hello-quarkus-jar:0.0.7 .
复制
docker run \ -i \ --rm \ -p 8080:8080 \ -e QUARKUS_LAUNCH_DEVMODE=true \ bolingcavalry/hello-quarkus-jar:0.0.7
复制
mvn quarkus:remote-dev -Dquarkus.live-reload.url=http://192.168.50.27:8080
复制
[INFO] Compiling 2 source files to /Users/will/temp/202203/01/001/hello-quarkus/target/test-classes Listening for transport dt_socket at address: 5005 2022-03-02 08:52:44,299 INFO [org.jbo.threads] (main) JBoss Threads version 3.4.2.Final 2022-03-02 08:52:45,488 INFO [io.qua.dep.QuarkusAugmentor] (main) Quarkus augmentation completed in 1532ms 2022-03-02 08:52:46,402 INFO [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending quarkus-app-dependencies.txt 2022-03-02 08:52:46,418 INFO [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending quarkus-run.jar 2022-03-02 08:52:46,424 INFO [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending app/hello-quarkus-1.0-SNAPSHOT.jar 2022-03-02 08:52:46,453 INFO [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Connected to remote server
复制
2022-03-02 08:57:40,568 INFO [io.qua.dep.dev.RuntimeUpdatesProcessor] (Remote dev client thread) File change detected: /Users/will/temp/202203/01/001/hello-quarkus/src/main/resources/application.properties 2022-03-02 08:57:40,572 INFO [io.qua.dep.dev.RuntimeUpdatesProcessor] (Remote dev client thread) Restarting quarkus due to changes in application.properties, HobbyResource.class. 2022-03-02 08:57:41,138 INFO [io.qua.dep.QuarkusAugmentor] (Remote dev client thread) Quarkus augmentation completed in 564ms 2022-03-02 08:57:41,143 INFO [io.qua.dep.dev.RuntimeUpdatesProcessor] (Remote dev client thread) Live reload total time: 1.082s 2022-03-02 08:57:41,556 INFO [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending lib/deployment/.io.quarkus.quarkus-resteasy-common-spi-2.7.1.Final.jar.baiduyun.uploading.cfg 2022-03-02 08:57:41,640 INFO [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending quarkus-run.jar 2022-03-02 08:57:41,649 INFO [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending app/hello-quarkus-1.0-SNAPSHOT.jar 2022-03-02 08:57:41,676 INFO [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending dev/app/application.properties
复制
2022-03-02 09:05:56,243 INFO [io.qua.dep.QuarkusAugmentor] (Remote dev client thread) Quarkus augmentation completed in 520ms 2022-03-02 09:05:56,248 INFO [io.qua.dep.dev.RuntimeUpdatesProcessor] (Remote dev client thread) Live reload total time: 0.985s 2022-03-02 09:05:56,610 INFO [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending dev/app/com/bolingcavalry/HobbyResource.class 2022-03-02 09:05:56,804 INFO [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending quarkus-run.jar 2022-03-02 09:05:56,811 INFO [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending app/hello-quarkus-1.0-SNAPSHOT.jar
复制