SpringBoot项目接入nacos后启动报错com.alibaba.nacos.api.exception.NacosException: null

  • A+
所属分类:Nacos

具体报错如下:

2019-10-29 08:27:52.391 ERROR [iop-special-topic-service,,,] 351644 --- [           main] o.s.c.a.nacos.NacosConfigProperties      : create config service error!properties=NacosConfigProperties{serverAddr='null', encode='null', group='DEFAULT_GROUP', sharedDataids='null', refreshableDataids='null', prefix='null', fileExtension='properties', timeout=3000, endpoint='null', namespace='null', accessKey='null', secretKey='null', contextPath='null', clusterName='null', name='null', activeProfiles=[]},e=,

com.alibaba.nacos.api.exception.NacosException: null
  at com.alibaba.nacos.api.config.ConfigFactory.createConfigService(ConfigFactory.java:45) ~[nacos-api-1.0.0.jar:na]
  at com.alibaba.nacos.api.NacosFactory.createConfigService(NacosFactory.java:41) ~[nacos-api-1.0.0.jar:na]
  at org.springframework.cloud.alibaba.nacos.NacosConfigProperties.configServiceInstance(NacosConfigProperties.java:347) ~[spring-cloud-alibaba-nacos-config-0.2.1.RELEASE.jar:0.2.1.RELEASE]
  at org.springframework.cloud.alibaba.nacos.client.NacosPropertySourceLocator.locate(NacosPropertySourceLocator.java:63) [spring-cloud-alibaba-nacos-config-0.2.1.RELEASE.jar:0.2.1.RELEASE]
  at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:97) [spring-cloud-context-2.1.1.RELEASE.jar:2.1.1.RELEASE]
  at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:649) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
  at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:373) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
  at com.cjsz.iopspecialtopicservice.IopSpecialTopicServiceApplication.main(IopSpecialTopicServiceApplication.java:12) [classes/:na]

原因:因为pom里加入了spring-cloud-starter-alibaba-nacos-config的依赖,但又没有用到动态配置,所以会报空指针的错,如果只需要用到naocs的服务注册与发现功能,只需要加上spring-cloud-starter-alibaba-nacos-discovery这个依赖即可。

ZPY

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: