在使用nacos配置时,不加版本号报错,spring boot 不能启动
<!-- 服务配置-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<!--<version>2.2.5.RELEASE</version>-->
</dependency>
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-07-28 18:26:49.399 ERROR 7988 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'baseManageController': Unsatisfied dependency expressed through field 'manageService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'manageServiceImpl' defined in file [D:\Repository\Repository\org\springframework\boot\spring-boot-starter-parent\2.3.6.RELEASE\target\classes\com\atguigu\gmall\product\service\impl\ManageServiceImpl.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.IllegalStateException: Unable to load cache item
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405) [spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at com.atguigu.gmall.product.ServiceProductApplication.main(ServiceProductApplication.java:13) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.3.6.RELEASE.jar:2.3.6.RELEASE]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'manageServiceImpl' defined in file [D:\Repository\Repository\org\springframework\boot\spring-boot-starter-parent\2.3.6.RELEASE\target\classes\com\atguigu\gmall\product\service\impl\ManageServiceImpl.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.IllegalStateException: Unable to load cache item
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1307) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
... 25 common frames omitted
Caused by: org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.IllegalStateException: Unable to load cache item
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:214) ~[spring-aop-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110) ~[spring-aop-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:471) ~[spring-aop-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:350) ~[spring-aop-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:299) ~[spring-aop-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:430) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1798) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
... 34 common frames omitted
Caused by: java.lang.IllegalStateException: Unable to load cache item
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:79) ~[spring-core-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) ~[spring-core-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:134) ~[spring-core-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:319) ~[spring-core-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:572) ~[spring-core-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:419) ~[spring-core-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:57) ~[spring-aop-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:205) ~[spring-aop-5.2.11.RELEASE.jar:5.2.11.RELEASE]
... 41 common frames omitted
Caused by: java.lang.LinkageError: loader constraint violation: when resolving overridden method "com.atguigu.gmall.product.service.impl.ManageServiceImpl$$EnhancerBySpringCGLIB$$8b7eb68f.getAttrInfo(Ljava/lang/Long;)Lcom/atguigu/gmall/model/product/BaseAttrInfo;" the class loader (instance of org/springframework/boot/devtools/restart/classloader/RestartClassLoader) of the current class, com/atguigu/gmall/product/service/impl/ManageServiceImpl$$EnhancerBySpringCGLIB$$8b7eb68f, and its superclass loader (instance of sun/misc/Launcher$AppClassLoader), have different Class objects for the type com/atguigu/gmall/model/product/BaseAttrInfo used in the signature
at java.lang.Class.forName0(Native Method) ~[na:1.8.0_162]
at java.lang.Class.forName(Class.java:348) ~[na:1.8.0_162]
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:571) ~[spring-core-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:363) ~[spring-core-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:585) ~[spring-core-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:110) ~[spring-core-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:108) ~[spring-core-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54) ~[spring-core-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) ~[na:1.8.0_162]
at java.util.concurrent.FutureTask.run(FutureTask.java) ~[na:1.8.0_162]
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61) ~[spring-core-5.2.11.RELEASE.jar:5.2.11.RELEASE]
... 48 common frames omitted
根据您提供的错误信息,似乎是由于缺少Nacos配置版本导致的错误。在使用Nacos配置时,您需要指定正确的依赖版本。
在您的代码中,您注释掉了标签,因此依赖的版本是默认值。您可以尝试将版本号添加到标签中,然后重新运行应用程序。例如,您可以尝试使用以下依赖版本:
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2.2.8.RELEASE</version>
</dependency>
请注意,版本号可能会随着时间的推移而更新,因此请确保使用最新的可用版本。
如果您已经指定了正确的版本但仍然遇到问题,请检查您的依赖冲突或版本不兼容问题。您可以使用Maven或Gradle等构建工具来帮助解决依赖问题。
另外,如果您在应用程序中启用了调试模式,请确保您已启用调试模式并重新运行应用程序。
如果你不想写版本号,你就需要在项目中或者父工程引入spring cloud alibaba dependencies
<dependencyManagement>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${你需要的版本号}</version>
</dependency>
</dependencyManagement>
你看springboot的自动装配里面有定义他的版本吗,父类有没有定义版本,没有的话就只能手动写一下