报错内容:
2022-04-25 10:09:01.575 ERROR 14136 — [ main]
o.s.c.a.nacos.NacosConfigProperties : create config service
error!properties=NacosConfigProperties{serverAddr=‘null’,
encode=‘null’, group=‘DEFAULT_GROUP’, prefix=‘null’,
fileExtension=‘properties’, timeout=3000, endpoint=‘null’,
namespace=‘null’, accessKey=‘null’, secretKey=‘null’,
contextPath=‘null’, clusterName=‘null’, name=‘null’,
sharedDataids=‘null’, refreshableDataids=‘null’, extConfig=null},e=,com.alibaba.nacos.api.exception.NacosException:
java.lang.reflect.InvocationTargetException at
com.alibaba.nacos.api.config.ConfigFactory.createConfigService(ConfigFactory.java:45)
~[nacos-api-1.1.4.jar:na] at
com.alibaba.nacos.api.NacosFactory.createConfigService(NacosFactory.java:43)
~[nacos-api-1.1.4.jar:na] at
org.springframework.cloud.alibaba.nacos.NacosConfigProperties.configServiceInstance(NacosConfigProperties.java:343)
~[spring-cloud-alibaba-nacos-config-0.2.2.RELEASE.jar:0.2.2.RELEASE]
at
org.springframework.cloud.alibaba.nacos.client.NacosPropertySourceLocator.locate(NacosPropertySourceLocator.java:63)
[spring-cloud-alibaba-nacos-config-0.2.2.RELEASE.jar:0.2.2.RELEASE]
at
org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:94)
[spring-cloud-context-2.1.0.RELEASE.jar:2.1.0.RELEASE] at
org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:623)
[spring-boot-2.1.11.RELEASE.jar:2.1.11.RELEASE] at
org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:367)
[spring-boot-2.1.11.RELEASE.jar:2.1.11.RELEASE] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
[spring-boot-2.1.11.RELEASE.jar:2.1.11.RELEASE] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
[spring-boot-2.1.11.RELEASE.jar:2.1.11.RELEASE] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1204)
[spring-boot-2.1.11.RELEASE.jar:2.1.11.RELEASE] at
com.demo.api.AppMember.main(AppMember.java:19) [classes/:na]
问题原因:
bootstrap.yml(bootstrap.properties)用来在程序引导时执行,应用于更加早期配置信息读取,如可以使用来配置application.yml中使用到参数等
application.yml(application.properties) 应用程序特有配置信息,可以用来配置后续各个模块中需使用的公共参数等。
解决方式:
将application.yml修改为bootstrap.yml,重新启动
备注:
如果重启之后出现新的报错:
2022-04-25 10:45:02.032 ERROR 12412 — [ main]
o.s.boot.SpringApplication : Application run failedorg.springframework.beans.factory.BeanCreationException: Error
creating bean with name ‘memberServiceImpl’: Injection of autowired
dependencies failed; nested exception is
java.lang.IllegalArgumentException: Could not resolve placeholder
‘demo.userName’ in value " d e m o . u s e r N a m e " a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . a n n o t a t i o n . A u t o w i r e d A n n o t a t i o n B e a n P o s t P r o c e s s o r . p o s t P r o c e s s P r o p e r t i e s ( A u t o w i r e d A n n o t a t i o n B e a n P o s t P r o c e s s o r . j a v a : 382 ) [ s p r i n g − b e a n s − 5.1.12. R E L E A S E . j a r : 5.1.12. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . p o p u l a t e B e a n ( A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . j a v a : 1404 ) [ s p r i n g