有人可以帮我吗?
我正在尝试在我正在从事的公司的一个项目中使用 Quarkus。
这是我的场景:
我工作的公司有一个本地环境,其中包含 CI 服务器和提供所有必需工件的 Artifactory。 CI 无权访问互联网,然后 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, Failures: 0, Errors: 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 Modler和 Quarkus 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>
然后就可以正常工作了!
关于quarkus - Quarkus : io. quarkus.bootstrap.BootstrapException 构建过程中出错:无法为 null 创建应用程序模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63457532/