【问题标题】:vertx redeploy arguments not work with exec-maven-pluginvertx 重新部署参数不适用于 exec-maven-plugin
【发布时间】:2021-03-07 11:29:45
【问题描述】:

我通过 Vert.x 启动器创建了一个项目,使用命令mvn exec:java 启动。

当我添加重新部署参数时,

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>${exec-maven-plugin.version}</version>
        <configuration>
          <mainClass>io.vertx.core.Launcher</mainClass>
          <arguments>
            <argument>run</argument>
            <argument>--redeploy=src/**/*.java</argument> <!-- just add this line -->
            <argument>${main.verticle}</argument>
          </arguments>
        </configuration>
      </plugin>

得到一个错误:

java.lang.Exception: classworlds configuration not specified nor found in the classpath
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:397)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

如何让这个 Vert.x 项目支持自动重新部署?

【问题讨论】:

  • &lt;argument&gt;--redeploy=src/**/*.java&lt;/argument&gt;移到列表底部是否有效?
  • 是的,默认启动器运行良好,但我想启用重新部署功能。

标签: vert.x redeploy


【解决方案1】:

exec:java 目标在当前 VM 中运行应用程序。因此,java.class.path 系统属性设置为启动 Maven 的类路径。

不幸的是,这是 Vert.x 重新部署模式用来确定应该作为分叉进程启动的 Vert.x 应用程序的类路径。 这就是缺少类并打印此异常的原因。

作为一种解决方法,您可以切换到exec:exec 目标和此配置:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>3.0.0</version>
  <configuration>
    <executable>java</executable>
    <commandlineArgs>-cp %classpath io.vertx.core.Launcher run --redeploy=src/**/*.java --on-redeploy="mvn compile" --launcher-class=io.vertx.core.Launcher ${main.verticle}</commandlineArgs>
  </configuration>
</plugin>

【讨论】:

  • 我提交了这个问题:github.com/vert-x3/vertx-starter/issues/142
  • 嗨 - 你知道在 vert.x 4 中是否可以在重新部署模式下启动 vertx?我和 OP 有同样的问题。
  • 您的答案适用于 vert.x 4,但是,当我修改源文件(我正在使用 kotlin)时,项目会刷新两次。
  • 不确定出了什么问题。你试过 Vert.x Maven 插件吗?支持重新部署
猜你喜欢
  • 1970-01-01
  • 2011-05-08
  • 2011-03-26
  • 2019-03-26
  • 1970-01-01
  • 2017-04-07
  • 2016-06-05
  • 2012-03-13
  • 1970-01-01
相关资源
最近更新 更多