org.springframework.aot.context.bootstrap.generator.generator.beandefinitiongenerationException:无法处理带有名称' xxx的bean并键入XXX&#xxx'

发布于 2025-02-10 02:19:46 字数 1584 浏览 2 评论 0原文

我想尝试春季。我有一个自定义的bean,但是当我运行“ spring-aot:生成”或“ spring-boot:build-image”时,我会得到以下例外。我不知道如何配置和添加提示密钥异常信息如

org.springframework.aot.context.bootstrap.generator.BeanDefinitionGenerationException: Failed to handle bean with name 'devInfoHeaderFilter' and type 'tablo.jhin.application.filters.DevInfoHeaderFilter'  at org.springframework.aot.context.bootstrap.generator.ApplicationContextAotProcessor.writeBeanDefinitions
...
Caused by: java.lang.IllegalStateException: Multiple privileged packages: [tablo.jhin.config, tablo.jhin.application.filters]at org.springframework.aot.context.bootstrap.generator.infrastructure.ProtectedAccessAnalysis.getPrivilegedPackageName
...
[ERROR] 
org.apache.maven.plugin.MojoExecutionException: Could not exec java
    at org.springframework.aot.maven.AbstractBootstrapMojo.forkJvm (AbstractBootstrapMojo.java:197)
...
Caused by: org.apache.maven.plugin.MojoExecutionException: Bootstrap code generator finished with exit code: 1
    at org.springframework.aot.maven.AbstractBootstrapMojo.forkJvm (AbstractBootstrapMojo.java:190)
    at org.springframework.aot.maven.GenerateMojo.execute (GenerateMojo.java:132)
....

“ tableo.jhin.config”下的内部类中如下所示,我配置了这样的bean:s​​ervicetracefilterconfiguration作为内部类

    @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
    static class ServletTraceFilterConfiguration implements NativeConfiguration {
        @Bean
        public DevInfoHeaderFilter devInfoHeaderFilter() {
            return new DevInfoHeaderFilter();
        }
}

I want to try SpringNative. I have a custom Bean, but when I run "spring-aot:generate" or "spring-boot:build-image", I get the following exception. I don't know how to configure and add Hint Key exception information is as follows

org.springframework.aot.context.bootstrap.generator.BeanDefinitionGenerationException: Failed to handle bean with name 'devInfoHeaderFilter' and type 'tablo.jhin.application.filters.DevInfoHeaderFilter'  at org.springframework.aot.context.bootstrap.generator.ApplicationContextAotProcessor.writeBeanDefinitions
...
Caused by: java.lang.IllegalStateException: Multiple privileged packages: [tablo.jhin.config, tablo.jhin.application.filters]at org.springframework.aot.context.bootstrap.generator.infrastructure.ProtectedAccessAnalysis.getPrivilegedPackageName
...
[ERROR] 
org.apache.maven.plugin.MojoExecutionException: Could not exec java
    at org.springframework.aot.maven.AbstractBootstrapMojo.forkJvm (AbstractBootstrapMojo.java:197)
...
Caused by: org.apache.maven.plugin.MojoExecutionException: Bootstrap code generator finished with exit code: 1
    at org.springframework.aot.maven.AbstractBootstrapMojo.forkJvm (AbstractBootstrapMojo.java:190)
    at org.springframework.aot.maven.GenerateMojo.execute (GenerateMojo.java:132)
....

In a internal class under the 'tablo.jhin.config', I configured such a Bean: ServiceTraceFilterConfiguration as an internal class

    @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
    static class ServletTraceFilterConfiguration implements NativeConfiguration {
        @Bean
        public DevInfoHeaderFilter devInfoHeaderFilter() {
            return new DevInfoHeaderFilter();
        }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文