[英]Maven multi module project with Quarkus in dev mode
I am new to Quarkus and try to use it in a Maven multi module project.我是 Quarkus 的新手,并尝试在 Maven 多模块项目中使用它。 My project is structured as followed:
我的项目结构如下:
- quarkustest (pom)
- quarkustest-application (jar)
- quarkustest-backend (pom)
- quarkustest-backend-rest-api (jar)
- quarkustest-dependencies (pom)
- quarkustest-parent (pom)
The application module executes the quarkus-maven-plugin with build-goal.应用程序模块使用 build-goal 执行 quarkus-maven-plugin。 The
quarkustest-backend-rest-api
contains a simple REST controller and thus also a beans.xml
in /src/main/resources/META-INF
. quarkustest-backend-rest-api
包含一个简单的 REST 控制器,因此也在/src/main/resources/META-INF
包含一个beans.xml
。 The rest-api-module is references by the application module. rest-api-module 是应用程序模块的引用。
If I package the whole project with mvn package
, the resulting runner-jar works as expected.如果我使用
mvn package
整个项目,则生成的 runner-jar 会按预期工作。 However, if I try to start the project in dev mode with mvn compile quarkus:dev
, I get following exception:但是,如果我尝试使用
mvn compile quarkus:dev
在开发模式下启动项目, mvn compile quarkus:dev
以下异常:
ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.0.0.CR2:dev (default-cli) on project quarkustest-application: Failed to run: Failed to resolve Quarkus application model: Failed to resolve dependencies for test.quarkustest:quarkustest-application:jar:1.0.0-SNAPSHOT: Could not find artifact test.quarkustest:quarkustest-backend-rest-api:jar:1.0.0-SNAPSHOT -> [Help 1]
错误] 无法在项目 quarkustest-application 上执行目标 io.quarkus:quarkus-maven-plugin:1.0.0.CR2:dev (default-cli):无法运行:无法解析 Quarkus 应用程序模型:无法解析依赖关系test.quarkustest:quarkustest-application:jar:1.0.0-SNAPSHOT: 找不到工件 test.quarkustest:quarkustest-backend-rest-api:jar:1.0.0-SNAPSHOT -> [帮助 1]
I am not quite sure how to solve this.我不太确定如何解决这个问题。 Is there any kind of best practice on multi module projects for Quarkus?
Quarkus 的多模块项目是否有任何最佳实践? Any obvious mistake I am doing here?
我在这里做的任何明显错误?
Edit 1 (relevant pom files)编辑1(相关pom文件)
quarkustest-application quarkustest-应用程序
<parent>
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../quarkustest-parent</relativePath>
</parent>
<artifactId>quarkustest-application</artifactId>
<dependencies>
<dependency>
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-backend-rest-api</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
quarkustest-parent夸克测试父
<parent>
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-dependencies</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../quarkustest-dependencies</relativePath>
</parent>
<artifactId>quarkustest-parent</artifactId>
<packaging>pom</packaging>
quarkustest-dependencies夸克测试依赖
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-dependencies</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
...
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-backend-rest-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus-plugin.version}</version>
</plugin>
</plugins>
</build>
quarkustest (aggregator) quarkustest(聚合器)
<parent>
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>quarkustest-parent</relativePath>
</parent>
<artifactId>quarkustest</artifactId>
<packaging>pom</packaging>
<modules>
<module>quarkustest-dependencies</module>
<module>quarkustest-parent</module>
<module>quarkustest-backend</module>
<module>quarkustest-application</module>
</modules>
If you've never ran mvn install
it might be because when you're in a subproject maven does not look in its sibling projects to resolve the dependencies, it only looks in the local maven repository which does not contain the dependency.如果您从未运行过
mvn install
可能是因为当您在子项目中时,maven 不会查看其兄弟项目来解析依赖项,它只会查看不包含依赖项的本地 maven 存储库。 If you have ran mvn install
it might be something else at play.如果你运行了
mvn install
它可能是其他东西在起作用。
Keep the quarkus-maven-plugin in the quarkustest-application and run将 quarkus-maven-plugin 保留在 quarkustest-application 中并运行
Now it will pick up changes in all submodules.现在它将获取所有子模块中的更改。
I was able to successfully run quarkus submodule in dev (with dependency to other module) in the following way:我能够通过以下方式在开发中成功运行 quarkus 子模块(依赖于其他模块):
-Dmaven.am -Dmaven.pl=<name-of-you-quarkus-module>
In parent pom define quarkus plugin:在父 pom 中定义 quarkus 插件:
<plugin> <groupId>io.quarkus</groupId> <artifactId>quarkus-maven-plugin</artifactId> <version>${quarkus-plugin.version}</version> </plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.