Unable to load instance for type com.ctrip.framework.apollo.util.ConfigUtil

springBoot项目需要加载Apollo配置; 引入 
@EnableApolloConfig
        <dependency>
            <groupId>com.ctrip.framework.apollo</groupId>
            <artifactId>apollo-client</artifactId>
            <version>1.6.2</version>
        </dependency>

服务启动失败;

{"@timestamp":"2022-12-08T15:29:35.501+08:00","@version":"1","service.name":"jt808","trace.id":"","transaction.id":"","log.level":"ERROR","log.logger":"org.springframework.boot.SpringApplication","remote_ip":"","local_ip":"","trace_id":"","request_uri":"","method_name":"org.springframework.boot.SpringApplication.reportFailure","line_number":"870","thread_name":"main","message":"Application run failed","stack_trace":"org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.ctrip.framework.apollo.spring.property.SpringValueDefinitionProcessor': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.ctrip.framework.apollo.spring.property.SpringValueDefinitionProcessor]: Constructor threw exception; nested exception is com.ctrip.framework.apollo.exceptions.ApolloConfigException: Unable to load instance for type com.ctrip.framework.apollo.util.ConfigUtil!\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1334)\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1232)\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)\r\n\tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213)\r\n\tat org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:135)\r\n\tat org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746)\r\n\tat org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564)\r\n\tat org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)\r\n\tat org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780)\r\n\tat org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:453)\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:343)\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1370)\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1359)\r\n\tat com.klicen.bigdata.Application.main(Application.java:27)\r\nCaused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.ctrip.framework.apollo.spring.property.SpringValueDefinitionProcessor]: Constructor threw exception; nested exception is com.ctrip.framework.apollo.exceptions.ApolloConfigException: Unable to load instance for type com.ctrip.framework.apollo.util.ConfigUtil!\r\n\tat org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:224)\r\n\tat org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1326)\r\n\t... 17 common frames omitted\r\nCaused by: com.ctrip.framework.apollo.exceptions.ApolloConfigException: Unable to load instance for type com.ctrip.framework.apollo.util.ConfigUtil!\r\n\tat com.ctrip.framework.apollo.build.ApolloInjector.getInstance(ApolloInjector.java:38)\r\n\tat com.ctrip.framework.apollo.spring.property.SpringValueDefinitionProcessor.<init>(SpringValueDefinitionProcessor.java:43)\r\n\tat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)\r\n\tat sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)\r\n\tat java.lang.reflect.Constructor.newInstance(Constructor.java:423)\r\n\tat org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211)\r\n\t... 19 common frames omitted\r\nCaused by: com.ctrip.framework.apollo.exceptions.ApolloConfigException: Unable to initialize Apollo Injector!\r\n\tat com.ctrip.framework.apollo.build.ApolloInjector.getInjector(ApolloInjector.java:22)\r\n\tat com.ctrip.framework.apollo.build.ApolloInjector.getInstance(ApolloInjector.java:35)\r\n\t... 25 common frames omitted\r\nCaused by: java.util.ServiceConfigurationError: com.ctrip.framework.apollo.internals.Injector: Provider com.ctrip.framework.apollo.internals.DefaultInjector could not be instantiated\r\n\tat java.util.ServiceLoader.fail(ServiceLoader.java:232)\r\n\tat java.util.ServiceLoader.access$100(ServiceLoader.java:185)\r\n\tat java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384)\r\n\tat java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)\r\n\tat java.util.ServiceLoader$1.next(ServiceLoader.java:480)\r\n\tat com.ctrip.framework.foundation.internals.ServiceBootstrap.loadFirst(ServiceBootstrap.java:19)\r\n\tat com.ctrip.framework.apollo.build.ApolloInjector.getInjector(ApolloInjector.java:20)\r\n\t... 26 common frames omitted\r\nCaused by: com.ctrip.framework.apollo.exceptions.ApolloConfigException: Unable to initialize Guice Injector!\r\n\tat com.ctrip.framework.apollo.internals.DefaultInjector.<init>(DefaultInjector.java:32)\r\n\tat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)\r\n\tat sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)\r\n\tat java.lang.reflect.Constructor.newInstance(Constructor.java:423)\r\n\tat java.lang.Class.newInstance(Class.java:442)\r\n\tat java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)\r\n\t... 30 common frames omitted\r\nCaused by: com.google.common.util.concurrent.ExecutionError: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Lcom/google/gson/Gson;\r\n\tat com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2212)\r\n\tat com.google.common.cache.LocalCache.get(LocalCache.java:4053)\r\n\tat com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4057)\r\n\tat com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4986)\r\n\tat com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4992)\r\n\tat com.google.inject.internal.FailableCache.get(FailableCache.java:54)\r\n\tat com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:49)\r\n\tat com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:155)\r\n\tat com.google.inject.internal.InjectorImpl.initializeBinding(InjectorImpl.java:592)\r\n\tat com.google.inject.internal.AbstractBindingProcessor$Processor.initializeBinding(AbstractBindingProcessor.java:173)\r\n\tat com.google.inject.internal.AbstractBindingProcessor$Processor.lambda$scheduleInitialization$0(AbstractBindingProcessor.java:160)\r\n\tat com.google.inject.internal.ProcessedBindingData.initializeBindings(ProcessedBindingData.java:49)\r\n\tat com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:124)\r\n\tat com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:108)\r\n\tat com.google.inject.Guice.createInjector(Guice.java:87)\r\n\tat com.google.inject.Guice.createInjector(Guice.java:69)\r\n\tat com.google.inject.Guice.createInjector(Guice.java:59)\r\n\tat com.ctrip.framework.apollo.internals.DefaultInjector.<init>(DefaultInjector.java:30)\r\n\t... 36 common frames omitted\r\nCaused by: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Lcom/google/gson/Gson;\r\n\tat com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2212)\r\n\tat com.google.common.cache.LocalCache.get(LocalCache.java:4053)\r\n\tat com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4057)\r\n\tat com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4986)\r\n\tat com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4992)\r\n\tat com.google.inject.internal.FailableCache.get(FailableCache.java:54)\r\n\tat com.google.inject.internal.MembersInjectorStore.get(MembersInjectorStore.java:69)\r\n\tat com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:75)\r\n\tat com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:30)\r\n\tat com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:38)\r\n\tat com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:34)\r\n\tat com.google.inject.internal.FailableCache$1.load(FailableCache.java:43)\r\n\tat com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3628)\r\n\tat com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2336)\r\n\tat com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2295)\r\n\tat com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2208)\r\n\t... 53 common frames omitted\r\nCaused by: java.lang.NoClassDefFoundError: Lcom/google/gson/Gson;\r\n\tat java.lang.Class.getDeclaredFields0(Native Method)\r\n\tat java.lang.Class.privateGetDeclaredFields(Class.java:2583)\r\n\tat java.lang.Class.getDeclaredFields(Class.java:1916)\r\n\tat com.google.inject.internal.DeclaredMembers.getDeclaredFields(DeclaredMembers.java:34)\r\n\tat com.google.inject.spi.InjectionPoint.getDeclaredFields(InjectionPoint.java:753)\r\n\tat com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:663)\r\n\tat com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:376)\r\n\tat com.google.inject.internal.MembersInjectorStore.createWithListeners(MembersInjectorStore.java:92)\r\n\tat com.google.inject.internal.MembersInjectorStore.access$000(MembersInjectorStore.java:40)\r\n\tat com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:49)\r\n\tat com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:45)\r\n\tat com.google.inject.internal.FailableCache$1.load(FailableCache.java:43)\r\n\tat com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3628)\r\n\tat com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2336)\r\n\tat com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2295)\r\n\tat com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2208)\r\n\t... 68 common frames omitted\r\nCaused by: java.lang.ClassNotFoundException: com.google.gson.Gson\r\n\tat java.net.URLClassLoader.findClass(URLClassLoader.java:382)\r\n\tat java.lang.ClassLoader.loadClass(ClassLoader.java:424)\r\n\tat sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)\r\n\tat java.lang.ClassLoader.loadClass(ClassLoader.java:357)\r\n\t... 84 common frames omitted\r\n"}
Disconnected from the target VM, address: '127.0.0.1:23256', transport: 'socket'

修改配置:

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.9</version>
        </dependency>

解决。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值