將原生的改動極速同步到遠端伺服器端,並自動生效,掌握此技能,開發偵錯會更高效
這裡分類和彙總了欣宸的全部原創(含配套原始碼):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