当前位置: 首页 > 知识库问答 >
问题:

使用JLink JRE的Spring Boot

许胡非
2023-03-14

我试图在Java 11中使用jlink为Spring Boot应用程序创建一个最小化的jre。我已经能够用完整的Java 11 jre运行它,但是我得到了一个stacktrace,我很难破译它。我假设根本原因是某种依赖冲突,因为它适用于完整的jre,而不是子集。

我使用的是spring boot 1.5.19,目前包含的模块有:java。base,java。日志记录,java。仪器,java。sql,java。命名和java。桌面

让我知道我可以提供什么其他信息。谢谢

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'propertySourceBootstrapConfiguration': Unsatisfied dependency expressed through field 'propertySourceLocators'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'consulPropertySourceLocator' defined in org.springframework.cloud.consul.config.ConsulConfigBootstrapConfiguration$ConsulPropertySourceConfiguration: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.cloud.consul.config.ConsulPropertySourceLocator$$EnhancerBySpringCGLIB$$9f7ea6c1
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:364)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1269)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:187)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:102)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:68)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
    at ServiceConfiguration.main(ServiceConfiguration.java:34)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'consulPropertySourceLocator' defined in org.springframework.cloud.consul.config.ConsulConfigBootstrapConfiguration$ConsulPropertySourceConfiguration: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.cloud.consul.config.ConsulPropertySourceLocator$$EnhancerBySpringCGLIB$$9f7ea6c1
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1314)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1280)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1178)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1094)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:583)
    ... 30 common frames omitted
Caused by: org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.cloud.consul.config.ConsulPropertySourceLocator$$EnhancerBySpringCGLIB$$9f7ea6c1
    at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:215)
    at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:109)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:466)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:349)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:298)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:421)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1635)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
    ... 42 common frames omitted
Caused by: org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.cloud.consul.config.ConsulPropertySourceLocator$$EnhancerBySpringCGLIB$$9f7ea6c1
    at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:76)
    at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:201)
    ... 49 common frames omitted
Caused by: java.lang.InstantiationException: org.springframework.cloud.consul.config.ConsulPropertySourceLocator$$EnhancerBySpringCGLIB$$9f7ea6c1
    at java.base/java.lang.Class.newInstance(Unknown Source)
    at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:73)
    ... 50 common frames omitted
Caused by: java.lang.NoSuchMethodException: org.springframework.cloud.consul.config.ConsulPropertySourceLocator$$EnhancerBySpringCGLIB$$9f7ea6c1.<init>()
    at java.base/java.lang.Class.getConstructor0(Unknown Source)
    ... 52 common frames omitted

共有2个答案

秦学林
2023-03-14

在这种情况下,简短的答案是将“jdk.unsupported”模块添加到Jlink的模块议论文列表中。

我这样做是基于这样一个事实,即我遇到了类似的问题(具有类似的stackstrace),但在尝试使用JDK17和SpringBoot项目构建自定义JRE时。这是帮助我解决问题的堆栈溢出帖子:NoSuchMethod odException:springframework.boot.autoconfigure.http.HttpMessageConverters

万俟小林
2023-03-14

Spring Boot 2.1. x正式支持Java11

 类似资料:
  • 我尝试将Spring Boot与HikariDataSource配合使用,但出现了错误。断管怎么配置比较好还是用c3p0比较好?我正在使用这个配置 我使用: 和 springboot 版本 1.4.2.RELEASE

  • 我在Scala2.11.1和Hzaelcast 3.5中使用kryo进行序列化。我试图将数据放在hazelcast映射中,但我得到了KryoException 下面是我的用户类序列化程序 现在,当我将用户类对象从Hcast客户端放入相应的映射中时,如下所示 它给了我这些例外: 以下是中的 请帮帮我!!

  • 使用SpringBoot创建了一个自定义jar,用于数据库表上的CRUD操作。其目的是使其成为一个实用程序jar,以便其他服务或应用程序可以将此jar用于该表上的任何操作。以下是我遵循的步骤: 1)。在REST SERVICE的pom.xml中添加此jar条目并成功构建。2)。在REST SERVICE的控制器内自动生成实用程序jar的服务类。 但是当我启动REST服务(服务是在spring bo

  • 本文向大家介绍解析SpringBoot @EnableAutoConfiguration的使用,包括了解析SpringBoot @EnableAutoConfiguration的使用的使用技巧和注意事项,需要的朋友参考一下 刚做后端开发的时候,最早接触的是基础的spring,为了引用二方包提供bean,还需要在xml中增加对应的包<context:component-scan base-packa

  • 本文向大家介绍webpack proxy 使用(代理的使用),包括了webpack proxy 使用(代理的使用)的使用技巧和注意事项,需要的朋友参考一下 为什么要写篇文章 这两天的开发中遇到一些需要代理才能解决的问题, 在这里记录一下, 方便以后的查阅. 为什么要用代理 跨域 在开发过程中, 我们的开发环境一般都是http:// localhost, 但是如果需要请求的数据不在本地, 那么我们就

  • 如何使用Spring RestTemplate发送GET请求?其他问题都用了POST,但我需要用get。当我运行这个程序时,程序继续工作,但似乎网络堵塞了,因为它在一个AsyncTask中,当我单击这个按钮后试图运行另一个AsyncTask时,它们将无法工作。 我试着做

  • 问题内容: 最近,我尝试了解 java.math.MathContext 的用法,但未能正确理解。它用于四舍五入。如果是,为什么不四舍五入十进制数字,甚至尾数部分。 从API文档中,我知道它遵循,和规范中指定的标准,但是我没有让他们在线阅读。 如果您对此有任何想法,请告诉我。 问题答案: @贾坦 谢谢您的回答。这说得通。您能否在BigDecimal#round方法的上下文中向我解释MathCont

  • 主要内容:下载 Nexus 3,启动 nexus 服务,访问 nexus 3.x目前 Nexus 分为 Nexus 2 和 Nexus 3 两个大版本,它们是并行的关系。与 Nexus 2 相比,Nexus 3 具有很多优势,例如支持更多的仓库格式、优化了用户的使用界面以及更加强大的搜索功能等等。 目前使用最多的,运行最稳定是 Nexus 2,但随着 Nexus 3 对 Maven 的支持越来越稳定,很多公司和组织都陆续开始使用 Nexus 3。 本节我们将介绍 Nexus