GraalVM本机映像在Springdoc依赖项上失败。

huangapple go评论147阅读模式
英文:

GraalVM Native Image failing on Springdoc dependency

问题

我正在尝试使用Spring Boot和GraalVM Native Image创建一个示例应用程序,但是一旦我添加了Springdoc的依赖,生成的可执行文件就不再工作,出现了以下错误:

 java.lang.IllegalStateException: Error processing condition on org.springdoc.core.SpringDocConfiguration.springdocBeanFactoryPostProcessor2
        ...
Caused by: java.lang.IllegalStateException: java.io.FileNotFoundException: class path resource [org/springdoc/core/CacheOrGroupedOpenApiCondition$OnCacheDisabled.class] cannot be opened because it does not exist
        ...

我的当前依赖如下:

dependencies {
    implementation ('org.springframework.boot:spring-boot-starter-web') {
        exclude group: 'org.apache.tomcat.embed', module: 'tomcat-embed-websocket'
    }
    implementation("org.springframework.boot:spring-boot-starter-actuator")
    // Lombok
    compileOnly("org.projectlombok:lombok")
    annotationProcessor("org.projectlombok:lombok")

    testCompileOnly("org.projectlombok:lombok")
    testAnnotationProcessor("org.projectlombok:lombok")

    // https://mvnrepository.com/artifact/org.slf4j/jcl-over-slf4j
    implementation('org.slf4j:jcl-over-slf4j:2.0.0-alpha1')
    implementation('org.springdoc:springdoc-openapi-webmvc-core:1.4.4')
}

一切都正常工作,直到我添加了SpringDoc。我已经尝试通过在构建时使用--initialize-at-build-time添加一些springdoc包,但没有成功。

我正在使用com.github.ayltai.spring-graalvm-native-plugin来处理Gradle任务,我的依赖关系如下:

dependencies {
    implementation ('org.springframework.boot:spring-boot-starter-web') {
        exclude group: 'org.apache.tomcat.embed', module: 'tomcat-embed-websocket'
    }
    implementation("org.springframework.boot:spring-boot-starter-actuator")
    // Lombok
    compileOnly("org.projectlombok:lombok")
    annotationProcessor("org.projectlombok:lombok")

    testCompileOnly("org.projectlombok:lombok")
    testAnnotationProcessor("org.projectlombok:lombok")

    // https://mvnrepository.com/artifact/org.slf4j/jcl-over-slf4j
    implementation('org.slf4j:jcl-over-slf4j:2.0.0-alpha1')
    implementation('org.springdoc:springdoc-openapi-webmvc-core:1.4.4')
}

欢迎提供任何线索。

英文:

I am trying to create a sample application using spring boot and GraalVM Native Image, however as soon as I add the dependency for Springdoc the generated executable is no longer working due to the following:

 java.lang.IllegalStateException: Error processing condition on org.springdoc.core.SpringDocConfiguration.springdocBeanFactoryPostProcessor2
        at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60) ~[poc-graalvm-native.exe:na]
        at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[na:na]
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:184) ~[na:na]
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144) ~[na:na]
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120) ~[na:na]
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331) ~[poc-graalvm-native.exe:na]
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236) ~[poc-graalvm-native.exe:na]
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:280) ~[na:na]
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96) ~[na:na]
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:707) ~[na:na]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533) ~[na:na]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[na:na]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[poc-graalvm-native.exe:na]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[poc-graalvm-native.exe:na]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[poc-graalvm-native.exe:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[poc-graalvm-native.exe:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[poc-graalvm-native.exe:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[poc-graalvm-native.exe:na]
        at c.b.t.graal.GraalVMApplicationPoc.main(GraalVMApplicationPoc.java:31) [poc-graalvm-native.exe:na]
Caused by: java.lang.IllegalStateException: java.io.FileNotFoundException: class path resource [org/springdoc/core/CacheOrGroupedOpenApiCondition$OnCacheDisabled.class] cannot be opened because it does not exist
        at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$MemberConditions.getMetadata(AbstractNestedCondition.java:149) ~[poc-graalvm-native.exe:na]
        at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$MemberConditions.getMemberConditions(AbstractNestedCondition.java:121) ~[poc-graalvm-native.exe:na]
        at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$MemberConditions.<init>(AbstractNestedCondition.java:114) ~[poc-graalvm-native.exe:na]
        at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition.getMatchOutcome(AbstractNestedCondition.java:62) ~[poc-graalvm-native.exe:na]
        at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[poc-graalvm-native.exe:na]
        ... 18 common frames omitted
Caused by: java.io.FileNotFoundException: class path resource [org/springdoc/core/CacheOrGroupedOpenApiCondition$OnCacheDisabled.class] cannot be opened because it does not exist
        at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180) ~[poc-graalvm-native.exe: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) ~[poc-graalvm-native.exe:na]
        ... 22 common frames omitted

My current dependencies are :

dependencies {
    implementation ('org.springframework.boot:spring-boot-starter-web') {
        exclude group : 'org.apache.tomcat.embed', module : 'tomcat-embed-websocket'
    }
    implementation("org.springframework.boot:spring-boot-starter-actuator")
    // Lombok
    compileOnly("org.projectlombok:lombok")
    annotationProcessor("org.projectlombok:lombok")

    testCompileOnly("org.projectlombok:lombok")
    testAnnotationProcessor("org.projectlombok:lombok")

    // https://mvnrepository.com/artifact/org.slf4j/jcl-over-slf4j
    implementation('org.slf4j:jcl-over-slf4j:2.0.0-alpha1')
    implementation('org.springdoc:springdoc-openapi-webmvc-core:1.4.4')
}

Everything was working fine until I added SpringDoc.
Already tried to add some springdoc packages to --initialize-at-build-time without success.

I am using com.github.ayltai.spring-graalvm-native-plugin to handle the gradle task and my dependencies are:

dependencies {
    implementation ('org.springframework.boot:spring-boot-starter-web') {
        exclude group : 'org.apache.tomcat.embed', module : 'tomcat-embed-websocket'
    }
    implementation("org.springframework.boot:spring-boot-starter-actuator")
    // Lombok
    compileOnly("org.projectlombok:lombok")
    annotationProcessor("org.projectlombok:lombok")

    testCompileOnly("org.projectlombok:lombok")
    testAnnotationProcessor("org.projectlombok:lombok")

    // https://mvnrepository.com/artifact/org.slf4j/jcl-over-slf4j
    implementation('org.slf4j:jcl-over-slf4j:2.0.0-alpha1')
    implementation('org.springdoc:springdoc-openapi-webmvc-core:1.4.4')
}

Any hint would be appreciated.

答案1

得分: 1

v1.5.9 起,springdoc-openapi 完全支持 在使用 spring-native 时的 GraalVM。

无需额外配置。

英文:

Since v1.5.9springdoc-openapi fully supports GraalVM with spring-native.

No additional configuration required.

答案2

得分: 0

添加这个依赖springdoc-openapi-native

英文:

Add this dependency springdoc-openapi-native

huangapple
  • 本文由 发表于 2020年8月18日 23:49:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/63472199.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定