使用Quarkus构建过程中出错:io.quarkus.bootstrap.BootstrapException:无法为null创建应用程序模型

问题描述

有人,你能帮我吗?

我正在尝试在我正在从事的公司的项目中使用Quarkus。

这是我的情况:

我正在工作的公司拥有一个带有CI服务器和提供所有必需工件的Artifactory的本地环境。 CI没有授予访问Internet的授权访问权限,然后Artifactory服务器负责带来所有外部工件。我们有很多使用相同CI构建的spring-boot应用程序...因此,我假设我们的CI和Artifactory都已正确配置。

这是我的问题:

我们的CI服务器已执行“ mvn package”命令,并显示以下错误,但此错误是在测试阶段发生的:

[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Running myproject.resources.HelloResourceTest
[ERROR] Tests run: 1,Failures: 0,Errors: 1,Skipped: 0,Time elapsed: 127.996 s <<< FAILURE! - in myproject.resources.HelloResourceTest
[ERROR] myproject.resources.HelloResourceTest.testHelloEndpoint  Time elapsed: 0.016 s  <<< ERROR!
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR]   HelloResourceTest.testHelloEndpoint » Runtime io.quarkus.bootstrap.BootstrapEx...
[INFO]
[ERROR] Tests run: 1,Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] myproject.............. ............................ FAILURE [02:29 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:41 min
[INFO] Finished at: 2020-08-17T18:38:56Z
[INFO] ------------------------------------------------------------------------

但是测试的目标类没有发生什么特别的事情:

package myproject.resources;

import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;

@QuarkusTest
public class HelloResourceTest {

    @Test
    public void testHelloEndpoint() {
        given()
          .when().get("/hello")
          .then()
             .statusCode(200)
             .body(is("Ops!"));
    }

}

这是目标资源的实现:

package myproject.resources;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.jboss.logging.Logger;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/hello")
public class HelloResource {

    private static final Logger LOG = Logger.getLogger(HelloResource.class);

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
       return "Ops!";
    }
}

然后我执行了'mvn package -e -X',并捕获了此异常消息:

    java.lang.RuntimeException
    java.lang.RuntimeException: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for null
    Cased by: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for null
    Caused by: java.lang.RuntimeException: Failed to create application model resolver for /home/dearrudam/myproject
    Caused by: io.quarkus.bootstrap.resolver.maven.BootstrapMavenException: Failed to read artifact descriptor for myproject:myproject:pom:1.0-SNAPSHOT
    Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for myproject:myproject:pom:1.0-SNAPSHOT
    Caused by: org.apache.maven.model.resolution.UnresolvableModelException: Could not transfer artifact io.quarkus:quarkus-universe-bom:pom:1.7.0.Final from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/io/quarkus/quarkus-universe-bom/1.7.0.Final/quarkus-universe-bom-1.7.0.Final.pom
    Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact io.quarkus:quarkus-universe-bom:pom:1.7.0.Final from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/io/quarkus/quarkus-universe-bom/1.7.0.Final/quarkus-universe-bom-1.7.0.Final.pom
    Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact io.quarkus:quarkus-universe-bom:pom:1.7.0.Final from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/io/quarkus/quarkus-universe-bom/1.7.0.Final/quarkus-universe-bom-1.7.0.Final.pom
    Caused by: org.apache.maven.wagon.TransferFailedException: Transfer failed for https://repo.maven.apache.org/maven2/io/quarkus/quarkus-universe-bom/1.7.0.Final/quarkus-universe-bom-1.7.0.Final.pom
    Caused by: org.apache.http.conn.HttpHostConnectException: Connect to repo.maven.apache.org:443 [repo.maven.apache.org/199.232.64.215] failed: Connection timed out (Connection timed out)
    Caused by: java.net.ConnectException: Connection timed out (Connection timed out)

为什么要尝试访问repo.maven.apache.org而不是我的本地Artifactory?

谢谢!

解决方法

我想感谢Falko ModlerQuarkus team的帮助!

解决方案详细信息:https://github.com/quarkusio/quarkus/issues/11433

总而言之,我遵循Falko的指示,该指示是将以下配置添加到maven-surefire-plugin系统属性中:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${surefire-plugin.version}</version>
    <configuration>
        <systemPropertyVariables>
            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
            <maven.home>${maven.home}</maven.home>
            <maven.settings>${session.request.userSettingsFile.path}</maven.settings>
        </systemPropertyVariables>
    </configuration>
</plugin>

然后正常工作!

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...