问题描述
追求学习GraalVM + SpringBoot的详细信息时,我正在研究仅具有少量操作和功能的示例应用程序。 其中之一是可以公开SpringDoc端点(当前使用1.4.5版本)。 即使已正确编译了应用程序并启动了本机映像可执行文件,但在开始配置内容后也会引发异常:
org.springframework.beans.factory.BeanDefinitionStoreException: @Configuration classes need to be marked as proxyBeanMethods=false. Found: [org.springdoc.core.SpringDocConfigProperties,org.springdoc.core.SpringDocConfiguration,org.springdoc.core.SwaggerUiConfigParameters,org.springdoc.core.SwaggerUiConfigProperties,org.springdoc.core.SwaggerUiOAuthProperties,org.springdoc.webmvc.core.SpringDocWebMvcConfiguration,org.springdoc.webmvc.ui.SwaggerConfig]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:71) ~[poc-graalvm-native.exe:na]
我已经具有以下依赖项:
implementation("org.springframework.experimental:spring-graalvm-native:0.7.1")
implementation("org.springframework.boot:spring-boot-configuration-processor")
annotationProcessor("org.springframework:spring-context-indexer:5.2.4.RELEASE")
在我的主班上也有@SpringBootApplication(proxyBeanMethods = false)
。
在没有proxyBeanMethods = false属性的情况下,@ Configuration类的情况是否有解决方法?
更新: 似乎配置已在Springdoc 1.4.6-Snapshot上更新。但是,还有其他事情开始抱怨:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'modelConverterRegistrar' defined in class path resource [org/springdoc/core/SpringDocConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springdoc.core.converters.ModelConverterRegistrar]: Factory method 'modelConverterRegistrar' threw exception; nested exception is java.lang.NullPointerException
不知道现在要去哪里...
解决方法
您需要确保使用最新的稳定版本:v1.4.6,这样您就不会收到上面提到的错误。
如果您想在春季使用此实验性功能,只需确保为graalVM使用spring官方插件即可。
您可以访问/ v3 / api-docs,没有任何问题。
请注意,用户界面无法在默认网址上使用(因为springdoc依赖于webjars定位器 您将不得不手动添加该版本...),因为在GraalVM端仍然缺少支持,然后会出现弹簧,以及此处讨论的内容:
- https://github.com/spring-projects-experimental/spring-graalvm-native/issues/157
- https://github.com/oracle/graal/issues/1108
按照之前的建议,请确保查看未完成的本机配置映像: