启用 spring sleuth 时 Spring boot native 应用程序无法启动 - invalidStateException BraveAutoConfiguration

标签 spring native illegalstateexception spring-native

我正在尝试使用 native 镜像 Maven 插件将 Spring boot 应用程序转换为 spring native 。 我按照此处所述设置 GraalVM 和 native 镜像 https://docs.spring.io/spring-native/docs/0.9.x/reference/htmlsingle/

原生镜像打包成功。但应用程序无法启动并出现错误

java.lang.IllegalStateException: Error processing condition on org.springframework.cloud.sleuth.autoconfig.brave.BraveAutoConfiguration
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60) ~[com.xxx.yyy.application:2.4.3]
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[na:na]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:489) ~[na:na]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:478) ~[na:na]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:140) ~[na:na]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:129) ~[na:na]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:342) ~[com.xxx.yyy.application:5.3.4]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:246) ~[com.xxx.yyy.application:5.3.4]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311) ~[na:na]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112) ~[na:na]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:745) ~[na:na]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:563) ~[na:na]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[na:na]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767) ~[com.xxx.yyy.application:2.4.3]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) ~[com.xxx.yyy.application:2.4.3]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) ~[com.xxx.yyy.application:2.4.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) ~[com.xxx.yyy.application:2.4.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311) ~[com.xxx.yyy.application:2.4.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) ~[com.xxx.yyy.application:2.4.3]
    at com.xxx.yyy.application.main(Application.java:23) ~[com.xxx.yyy.application:1.5-SNAPSHOT]
Caused by: java.lang.IllegalStateException: java.io.FileNotFoundException: class path resource [org/springframework/cloud/sleuth/autoconfig/brave/AnyTracerModePropertySetCondition$OnConcreteTracerMode.class] cannot be opened because it does not exist
    at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$MemberConditions.getMetadata(AbstractNestedCondition.java:149) ~[na:na]
    at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$MemberConditions.getMemberConditions(AbstractNestedCondition.java:121) ~[na:na]
    at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$MemberConditions.<init>(AbstractNestedCondition.java:114) ~[na:na]
    at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition.getMatchOutcome(AbstractNestedCondition.java:62) ~[com.xxx.yyy.application:2.4.3]
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[com.xxx.yyy.application:2.4.3]
    ... 19 common frames omitted
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/cloud/sleuth/autoconfig/brave/AnyTracerModePropertySetCondition$OnConcreteTracerMode.class] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180) ~[na:na]
    at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:55) ~[na:na]
    at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:49) ~[na:na]
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103) ~[na:na]
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81) ~[na:na]
    at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$MemberConditions.getMetadata(AbstractNestedCondition.java:146) ~[na:na]
    ... 23 common frames omitted

Spring 原生版本:0.9.0

<dependency>
  <groupId>org.springframework.experimental</groupId>
  <artifactId>spring-native</artifactId>
  <version>0.9.0</version>
</dependency>

Spring启动版本:2.4.3

 <parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.4.3</version>
  <relativePath/>
 </parent>

Spring云版本:2020.0.1

 <dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-dependencies</artifactId>
   <version>2020.0.1</version>
   <type>pom</type>
   <scope>import</scope>
 </dependency>

最佳答案

好的,我刚刚发现 Spring 原生还不支持 sleuth

Spring 初始化程序中的警告消息:

The following was discovered as part of building this project:
The following dependency is not known to work with Spring Native: 'Sleuth'. As a result, your application may not work as expected.

关于启用 spring sleuth 时 Spring boot native 应用程序无法启动 - invalidStateException BraveAutoConfiguration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66591972/

相关文章:

java - 需要 Spring Framework IllegalArgumentException 'dataSource' 或 'jdbcTemplate' JAVA

java - 在 Controller 中设置 "systems"属性并在某个方面访问该属性

java - 驱动程序可执行文件的路径必须由 webdriver.chrome.driver 设置;非法状态异常

java - native Android 教程给出错误

java - 致命崩溃 : Focus search returned a view that wasn't able to take focus

java - 无法在主线程上访问数据库,因为它可能会长时间锁定 UI 错误

java - JAR更新后Spring boot自动重启

java - 多 Maven 项目的 Spring AOP 问题

java - 我如何在类上应用 JNI 而不是将随机函数组合在一起?

android - 在 android native 中,Mediacodec.dequeueInputBuffer 不返回