spring-boot - Quarkus Jandex 索引无法解析 Artifact org.springframework :spring-web

标签 spring-boot maven cdi quarkus

我正在尝试在 Quarkus 中迁移 Spring Boot 应用程序。 经过一番尝试后,我发现并非所有的 beans 都被发现,因此我尝试遵循本指南并创建一个 jandex 索引 https://quarkus.io/guides/cdi-reference 。 除了 spring-web Artifact 之外,所有其他依赖项都很容易发现,但是当到了 spring-web 的时候,它会显示:

无法解析 Artifact org.springframework:spring-web:null

存储库应该是 https://mvnrepository.com/artifact/org.springframework/spring-web/4.3.28.RELEASE

这是我的 application.yaml 文件。

quarkus:
  http:
    port: 8998
  log:
    level: DEBUG
  index-dependency:
    bear-arch-rest:
      group-id: org.acme.bear
      artifact-id: bear-arch-rest
    bear-arch-core:
      group-id: org.acme.bear
      artifact-id: bear-arch-core
    bear-arch-exception:
      group-id: org.acme.bear
      artifact-id: bear-arch-exception
    spring-hateoas:
      group-id: org.springframework.hateoas
      artifact-id: spring-hateoas
    spring-web:
      group-id: org.springframework
      artifact-id: spring-web

然后,当我尝试构建项目时,它会显示一条错误消息:

[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.3.4.Final-redhat-00001:build (default) on project darwin-on-quarkus-rest: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR]     [error]: Build step io.quarkus.deployment.index.ApplicationArchiveBuildStep#build threw an exception: java.lang.RuntimeException: java.lang.RuntimeException: Could not resolve artifact org.springframework:spring-web:null. Please make sure it is present and contains a META-INF/MANIFEST.MF file. Note that artifacts that are part of the same project may not always be resolvable, in this case you should generate a META-INF/jandex.idx file instead using the Jandex Maven plugin.
[ERROR]     at io.quarkus.deployment.index.ApplicationArchiveBuildStep.getIndexDependencyPaths(ApplicationArchiveBuildStep.java:148)
[ERROR]     at io.quarkus.deployment.index.ApplicationArchiveBuildStep.scanForOtherIndexes(ApplicationArchiveBuildStep.java:110)
[ERROR]     at io.quarkus.deployment.index.ApplicationArchiveBuildStep.build(ApplicationArchiveBuildStep.java:97)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]     at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR]     at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:938)
[ERROR]     at io.quarkus.builder.BuildContext.run(BuildContext.java:273)
[ERROR]     at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
[ERROR]     at java.lang.Thread.run(Thread.java:748)
[ERROR]     at org.jboss.threads.JBossThread.run(JBossThread.java:479)
[ERROR] Caused by: java.lang.RuntimeException: Could not resolve artifact org.springframework:spring-web:null. Please make sure it is present and contains a META-INF/MANIFEST.MF file. Note that artifacts that are part of the same project may not always be resolvable, in this case you should generate a META-INF/jandex.idx file instead using the Jandex Maven plugin.
[ERROR]     at io.quarkus.deployment.index.ClassPathArtifactResolver.getArtifact(ClassPathArtifactResolver.java:68)
[ERROR]     at io.quarkus.deployment.index.ArtifactIndex.getPath(ArtifactIndex.java:14)
[ERROR]     at io.quarkus.deployment.index.ApplicationArchiveBuildStep.getIndexDependencyPaths(ApplicationArchiveBuildStep.java:136)
[ERROR]     ... 14 more
[ERROR] -> [Help 1]

我尝试使用分类器,但这没有改变任何东西。

当我尝试删除 quarkus.index-dependency.spring-web 属性并尝试构建时,它显示:

[INFO] --- quarkus-maven-plugin:1.3.4.Final-redhat-00001:build (default) @ darwin-on-quarkus-rest ---
[INFO] [org.jboss.threads] JBoss Threads version 3.1.1.Final-redhat-00001
[WARNING] [io.quarkus.arc.processor.BeanArchives] Failed to index org.springframework.web.filter.AbstractRequestLoggingFilter: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader
[INFO] [io.quarkus.arc.processor.IndexClassLookupUtils] Class for name: org.springframework.web.filter.AbstractRequestLoggingFilter was not found in Jandex index. Please ensure the class is part of the index.
[WARNING] [io.quarkus.arc.processor.BeanArchives] Failed to index org.springframework.scheduling.annotation.AsyncConfigurerSupport: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader
[INFO] [io.quarkus.arc.processor.IndexClassLookupUtils] Class for name: org.springframework.scheduling.annotation.AsyncConfigurerSupport was not found in Jandex index. Please ensure the class is part of the index.
[WARNING] [io.quarkus.arc.processor.BeanArchives] Failed to index org.springframework.web.servlet.config.annotation.WebMvcConfigurer: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader
[INFO] [io.quarkus.arc.processor.IndexClassLookupUtils] Class for name: org.springframework.web.servlet.config.annotation.WebMvcConfigurer was not found in Jandex index. Please ensure the class is part of the index.
[WARNING] [io.quarkus.arc.processor.BeanArchives] Failed to index org.springframework.web.servlet.HandlerInterceptor: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader
[INFO] [io.quarkus.arc.processor.IndexClassLookupUtils] Class for name: org.springframework.web.servlet.HandlerInterceptor was not found in Jandex index. Please ensure the class is part of the index.
[WARNING] [io.quarkus.arc.processor.BeanArchives] Failed to index org.springframework.beans.factory.DisposableBean: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader
[INFO] [io.quarkus.arc.processor.IndexClassLookupUtils] Class for name: org.springframework.beans.factory.DisposableBean was not found in Jandex index. Please ensure the class is part of the index.
[WARNING] [io.quarkus.arc.processor.BeanArchives] Failed to index org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader
[INFO] [io.quarkus.arc.processor.IndexClassLookupUtils] Class for name: org.springframework.http.converter.json.MappingJackson2HttpMessageConverter was not found in Jandex index. Please ensure the class is part of the index.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  05:45 min
[INFO] Finished at: 2020-08-03T14:30:48+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.3.4.Final-redhat-00001:build (default) on project darwin-on-quarkus-rest: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR]     [error]: Build step io.quarkus.arc.deployment.ArcProcessor#registerBeans threw an exception: java.lang.IllegalArgumentException: Producer method return type not found in index: org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
[ERROR]     at io.quarkus.arc.processor.Types.getProducerMethodTypeClosure(Types.java:176)
[ERROR]     at io.quarkus.arc.processor.Beans.createProducerMethod(Beans.java:172)
[ERROR]     at io.quarkus.arc.processor.BeanDeployment.findBeans(BeanDeployment.java:763)
[ERROR]     at io.quarkus.arc.processor.BeanDeployment.registerBeans(BeanDeployment.java:206)
[ERROR]     at io.quarkus.arc.processor.BeanProcessor.registerBeans(BeanProcessor.java:122)
[ERROR]     at io.quarkus.arc.deployment.ArcProcessor.registerBeans(ArcProcessor.java:262)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]     at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR]     at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:938)
[ERROR]     at io.quarkus.builder.BuildContext.run(BuildContext.java:273)
[ERROR]     at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
[ERROR]     at java.lang.Thread.run(Thread.java:748)
[ERROR]     at org.jboss.threads.JBossThread.run(JBossThread.java:479)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

感谢您的帮助!

最佳答案

我收到了 quarkus 支持人员的答复,你可以在那里找到它 https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/Quarkus.20CDI.3A.20Spring-Web.20Artifact.20Could.20Not.20Be.20Resolved .

简而言之:

  • 您必须使用 Quarkus 扩展来获取兼容依赖项列表,您可以在此处找到 https://quarkus.io/guides/#compatibility .
  • 如果您已经有 springboot 应用程序,迁移到 Quarkus 的唯一方法是更改​​很少的代码以遵守 Quarkus 的限制
    干杯

关于spring-boot - Quarkus Jandex 索引无法解析 Artifact org.springframework :spring-web,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63228985/

相关文章:

Spring安全+ session : Receive "Set-Cookie" header but not set in browser

java - 没有配置 CurrentSessionContext

java - Spring Boot多war应用集成测试

eclipse - EL 标签不能与 tomcat 7 中的 maven 一起使用

jakarta-ee - WELD-001408 在注入(inject)点带有限定符 [@Named] 的类型 [LdapService] 的依赖关系不满足

spring - 如何在 spring-boot-starter-data-rest 中为 Swagger 文档实现 snake_case?

spring-boot - 404 的 Spring Boot 自定义错误页面

java - CDI 为 bean 选择正确的范围

java - "Required filename-based automodules detected."警告是什么意思?

java - 尝试在 Tomcat 7 中使用 Jersey (JAX-RS) 和 Weld (CDI)。为 javax.annotation.ManagedBean 获取 noClassDefFoundError