目录
前言
系列文章目录
一、项目启动报错
1、报错截图
2、错误信息
二、解决方案
1.错误原因
2.排查建议
前言
本篇博客使用Spring Cloud 2021版本、Nacos 1.4.0、Spring Boot 2.7.6
系列文章目录
Spring Boot2.0系列教程合集、Spring Cloud系列教程合集、Spring Boot常见错误合集、Spring Cloud常见错误合集_zjh_746140129的博客-CSDN博客
以下是本篇文章正文内容,下面案例可供参考
一、项目启动报错
1、报错截图
2、错误信息
java.lang.IllegalArgumentException: Param 'serviceName' is illegal, serviceName is blank
at com.alibaba.nacos.api.naming.utils.NamingUtils.getGroupedName(NamingUtils.java:47) ~[nacos-api-1.4.2.jar:na]
at com.alibaba.nacos.client.naming.NacosNamingService.subscribe(NacosNamingService.java:457) ~[nacos-client-1.4.2.jar:na]
at com.alibaba.cloud.nacos.discovery.NacosWatch.start(NacosWatch.java:133) ~[spring-cloud-starter-alibaba-nacos-discovery-2021.0.1.0.jar:2021.0.1.0]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) [spring-context-5.3.22.jar:5.3.22]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) [spring-context-5.3.22.jar:5.3.22]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) [spring-context-5.3.22.jar:5.3.22]
at java.lang.Iterable.forEach(Iterable.java:75) ~[na:1.8.0_161]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) [spring-context-5.3.22.jar:5.3.22]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) [spring-context-5.3.22.jar:5.3.22]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935) ~[spring-context-5.3.22.jar:5.3.22]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.22.jar:5.3.22]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.0.jar:2.6.0]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-2.6.0.jar:2.6.0]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) ~[spring-boot-2.6.0.jar:2.6.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.0.jar:2.6.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.0.jar:2.6.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[spring-boot-2.6.0.jar:2.6.0]
at com.cloud.provider.ProviderApplication.main(ProviderApplication.java:26) ~[classes/:na]
二、解决方案
1.错误原因
在Spring Boot 2.4.x
的版本之后,对于bootstrap.properties和
bootstrap.yaml
配置文件,需要在pom中加入依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>3.1.0</version>
</dependency>
低版本的Spring Cloud有可能是spring.application.name
没有设置。我看网上还有的人说是discovery.service
没有设置,按理说这个不用设置,点进去会发现他默认就是取的${spring.application.name}
2.排查建议
如果低于Spring Boot 2.4版本的:
检查一下配置文件/Nacos配置中心是否设置spring.application.name
查看本地配置文件是否指定了Nacos作为配置中心地址
discovery.service这个不用设置,默认就是取${spring.application.name}
文章来源:https://www.toymoban.com/news/detail-508227.html
spring:
application:
name: provider
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848 #Nacos作为服务注册中心
# service: ${spring.application.name}
config:
server-addr: 127.0.0.1:8848 #Nacos作为配置中心地址
file-extension: yaml #指定yaml格式的配置
文章来源地址https://www.toymoban.com/news/detail-508227.html
到了这里,关于java.lang.IllegalArgumentException: Param ‘serviceName‘ is illegal, serviceName is blank 报错解决的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!