当前位置: 首页 > 知识库问答 >
问题:

在开发模式下运行的quarkus看不到pom dependecy

蓝昊天
2023-03-14

我试图用一个json rest接口编写一个quarkus应用程序,它应该依赖于一个外部库。我想在我的rest实现中从这个库调用一些方法。

因此,我从一个简单的quarkus rest应用程序开始

mvn io.quarkus:quarkus-maven-plugin:1.13.7.Final:create -DprojectGroupId=org.acme -DprojectArtifactId=getting-started -DclassName="org.acme.getting.started.GreetingResource" -Dpath="/hello
        <dependency>
            <groupId>com.examples</groupId>
            <artifactId>test-library</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.examples</groupId>
    <artifactId>test-library</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Test Library</name>
    <description>Some description</description>

    <properties>
        <!-- Override default JAVA target version -->
        <project.compiler.source>11</project.compiler.source>
        <project.compiler.target>11</project.compiler.target>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.10.5</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>           
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.22.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <useManifestOnlyJar>false</useManifestOnlyJar>
                    <useSystemClassLoader>false</useSystemClassLoader>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

我通过运行

~/apache-maven-3.8.1/bin/mvn compile install -s ~/.m2sb/settings.xml

成功之后,我尝试在quarkus开发模式下启动quarkus问候应用程序

~/apache-maven-3.8.1/bin/mvn compile quarkus:dev -s ~/.m2sb/settings.xml

我出错了

[INFO] --- quarkus-maven-plugin:1.13.7.Final:dev (default-cli) @ getting-started ---
Listening for transport dt_socket at address: 5005
Exception in thread "main" java.lang.RuntimeException: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for org.acme:getting-started::jar:1.0.0-SNAPSHOT
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:150)
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:63)
Caused by: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for org.acme:getting-started::jar:1.0.0-SNAPSHOT
        at io.quarkus.bootstrap.BootstrapAppModelFactory.resolveAppModel(BootstrapAppModelFactory.java:320)
        at io.quarkus.bootstrap.app.QuarkusBootstrap.bootstrap(QuarkusBootstrap.java:163)
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:143)
        ... 1 more
Caused by: io.quarkus.bootstrap.resolver.maven.BootstrapMavenException: Failed to resolve dependencies for org.acme:getting-started:jar:1.0.0-SNAPSHOT
        at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.resolveManagedDependencies(MavenArtifactResolver.java:273)
        at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.doResolveModel(BootstrapAppModelResolver.java:186)
        at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.resolveManagedModel(BootstrapAppModelResolver.java:152)
        at io.quarkus.bootstrap.BootstrapAppModelFactory.resolveAppModel(BootstrapAppModelFactory.java:306)
        ... 3 more
Caused by: org.eclipse.aether.resolution.DependencyResolutionException: Could not find artifact com.examples:test-library:jar:0.0.1-SNAPSHOT
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:357)
        at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.resolveManagedDependencies(MavenArtifactResolver.java:269)
        ... 6 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact com.examples:test-library:jar:0.0.1-SNAPSHOT
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:424)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:229)
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:340)
        ... 7 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact com.examples:test-library:jar:0.0.1-SNAPSHOT
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:414)
        ... 9 more

共有1个答案

养星汉
2023-03-14

您的~/.m2sb/settings.xml是否包含正确的localrepository路径?我无法复制它。事实上,如果我将test-library安装到默认的~/.m2/repository而不是~/.m2sb/repository,应用程序将无法在开发模式下启动,因为test-library将丢失。将它安装到~/.m2sb/repository实际上可以修复它。

 类似资料:
  • 我尝试从activator项目运行项目'play-scala':运行“activator New”控制台,选择“play-scala”模板,在项目文件夹中运行“activator run”。 但我总是有例外:

  • 我已经使用Quarkus开发模式()启动了我的应用程序,我希望能够调试它。 怎么能那么做?

  • 我试图运行测试在夸克斯:开发模式与一些Kafka测试。 问题是夸克斯:开发模式测试运行程序无法启动redpanda kafka容器。这是一个已知问题还是目前无法做到?

  • 但是当我启动服务器时,这个url不起作用: 出现错误警报: 有什么想法吗? 谢谢你,泰金。

  • 我有Vue.js前端应用程序和基于ExpressJS的nodeJS后端。ExpressJS还用作静态构建的Vue.js应用程序的web服务器 前端应用程序通过rest和WebSocket与express后端通信。它使用实例中的url主机,可以轻松地与后端通信 在生产模式下,当在静态expressJS服务器区域中构建应用程序时,一切工作都很完美 在开发模式下,Vue使用它自己的web服务器,并且基于

  • 我有一些带有Quarkus的java Web应用程序。并且它可以完美地使用runner.jar文件。但是当我使用Quarkus: dev模式时,它没有显示静态内容(只有白色背景)。而且那很奇怪,因为REST Services可以正常工作。而且是的我在编译源代码时将所有Web资源复制到main/Resources/META-INF中。