ToB企服应用市场:ToB评测及商务社交产业平台

标题: quarkus实战之四:远程热部署 [打印本页]

作者: 盛世宏图    时间: 2023-7-24 08:21
标题: quarkus实战之四:远程热部署
将本地的改动极速同步到远程服务端,并自动生效,掌握此技能,开发调试会更高效
欢迎访问我的GitHub

这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos
本篇概览


牢记来自官方的警告

在服务器上的运行方式

demo项目

  1. mvn "io.quarkus:quarkus-maven-plugin:create" \
  2.   -DprojectGroupId="com.bolingcavalry" \
  3.   -DprojectArtifactId="hello-quarkus" \
  4.   -DprojectVersion="1.0-SNAPSHOT" \
  5.   -DclassName="HobbyResource" \
  6.   -Dpath="actions"
复制代码
  1. package com.bolingcavalry;
  2. import org.eclipse.microprofile.config.inject.ConfigProperty;
  3. import javax.ws.rs.GET;
  4. import javax.ws.rs.Path;
  5. import javax.ws.rs.Produces;
  6. import javax.ws.rs.core.MediaType;
  7. import java.time.LocalDateTime;
  8. @Path("/actions")
  9. public class HobbyResource {
  10.     @ConfigProperty(name = "greeting.message")
  11.     String message;
  12.     @GET
  13.     @Produces(MediaType.TEXT_PLAIN)
  14.     public String hello() {
  15.         return message + ", Hello RESTEasy " + LocalDateTime.now();
  16.     }
  17. }
复制代码
  1. # 这是一个自定义属性,在业务代码中使用ConfigProperty注解取得其值
  2. greeting.message=message from configuration
  3. # 远程调试时用到的参数,可变jar,也就是支持热部署的jar
  4. quarkus.package.type=mutable-jar
  5. # 远程调试时用到的参数,为了安全起见,需要指定密码
  6. quarkus.live-reload.password=changeit
复制代码
制作docker镜像

  1. mvn clean package -U -DskipTests
复制代码
  1. docker build \
  2. -f src/main/docker/Dockerfile.jvm \
  3. -t bolingcavalry/hello-quarkus-jar:0.0.7 .
复制代码
在服务器运行

  1. docker run \
  2. -i \
  3. --rm \
  4. -p 8080:8080 \
  5. -e QUARKUS_LAUNCH_DEVMODE=true \
  6. bolingcavalry/hello-quarkus-jar:0.0.7
复制代码
远程热部署

  1. mvn quarkus:remote-dev -Dquarkus.live-reload.url=http://192.168.50.27:8080
复制代码
  1. [INFO] Compiling 2 source files to /Users/will/temp/202203/01/001/hello-quarkus/target/test-classes
  2. Listening for transport dt_socket at address: 5005
  3. 2022-03-02 08:52:44,299 INFO  [org.jbo.threads] (main) JBoss Threads version 3.4.2.Final
  4. 2022-03-02 08:52:45,488 INFO  [io.qua.dep.QuarkusAugmentor] (main) Quarkus augmentation completed in 1532ms
  5. 2022-03-02 08:52:46,402 INFO  [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending quarkus-app-dependencies.txt
  6. 2022-03-02 08:52:46,418 INFO  [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending quarkus-run.jar
  7. 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
  8. 2022-03-02 08:52:46,453 INFO  [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Connected to remote server
复制代码
  1. 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
  2. 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.
  3. 2022-03-02 08:57:41,138 INFO  [io.qua.dep.QuarkusAugmentor] (Remote dev client thread) Quarkus augmentation completed in 564ms
  4. 2022-03-02 08:57:41,143 INFO  [io.qua.dep.dev.RuntimeUpdatesProcessor] (Remote dev client thread) Live reload total time: 1.082s
  5. 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
  6. 2022-03-02 08:57:41,640 INFO  [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending quarkus-run.jar
  7. 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
  8. 2022-03-02 08:57:41,676 INFO  [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending dev/app/application.properties
复制代码
  1. 2022-03-02 09:05:56,243 INFO  [io.qua.dep.QuarkusAugmentor] (Remote dev client thread) Quarkus augmentation completed in 520ms
  2. 2022-03-02 09:05:56,248 INFO  [io.qua.dep.dev.RuntimeUpdatesProcessor] (Remote dev client thread) Live reload total time: 0.985s
  3. 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
  4. 2022-03-02 09:05:56,804 INFO  [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending quarkus-run.jar
  5. 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
复制代码
欢迎关注博客园:程序员欣宸

学习路上,你不孤单,欣宸原创一路相伴...

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4