Nacos开启鉴权后读取不到配置文件,get data from Nacos error,dataId:http error, code=403,dataId=

这篇具有很好参考价值的文章主要介绍了Nacos开启鉴权后读取不到配置文件,get data from Nacos error,dataId:http error, code=403,dataId=。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

报错信息

2024-01-09 11:05:27.807 ERROR 72921 --- [           main] c.a.c.n.c.NacosPropertySourceBuilder     : get data from Nacos error,dataId:zongdapao-order 

com.alibaba.nacos.api.exception.NacosException: http error, code=403,dataId=zongdapao-order,group=DEFAULT_GROUP,tenant=
	at com.alibaba.nacos.client.config.impl.ClientWorker$ConfigRpcTransportClient.queryConfig(ClientWorker.java:1035) ~[nacos-client-2.0.3.jar:na]
	at com.alibaba.nacos.client.config.impl.ClientWorker.getServerConfig(ClientWorker.java:407) ~[nacos-client-2.0.3.jar:na]
	at com.alibaba.nacos.client.config.NacosConfigService.getConfigInner(NacosConfigService.java:166) ~[nacos-client-2.0.3.jar:na]
	at com.alibaba.nacos.client.config.NacosConfigService.getConfig(NacosConfigService.java:94) ~[nacos-client-2.0.3.jar:na]
	at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.loadNacosData(NacosPropertySourceBuilder.java:85) [spring-cloud-starter-alibaba-nacos-config-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.build(NacosPropertySourceBuilder.java:73) [spring-cloud-starter-alibaba-nacos-config-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosPropertySource(NacosPropertySourceLocator.java:199) [spring-cloud-starter-alibaba-nacos-config-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosDataIfPresent(NacosPropertySourceLocator.java:186) [spring-cloud-starter-alibaba-nacos-config-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadApplicationConfiguration(NacosPropertySourceLocator.java:141) [spring-cloud-starter-alibaba-nacos-config-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.locate(NacosPropertySourceLocator.java:103) [spring-cloud-starter-alibaba-nacos-config-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.cloud.bootstrap.config.PropertySourceLocator.locateCollection(PropertySourceLocator.java:52) [spring-cloud-context-2.2.9.RELEASE.jar:2.2.9.RELEASE]
	at org.springframework.cloud.bootstrap.config.PropertySourceLocator.locateCollection(PropertySourceLocator.java:47) [spring-cloud-context-2.2.9.RELEASE.jar:2.2.9.RELEASE]
	at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:98) [spring-cloud-context-2.2.9.RELEASE.jar:2.2.9.RELEASE]
	at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:623) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
	at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:367) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1247) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1236) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
	at com.zzx.zongdapao.OrderMain.main(OrderMain.java:21) [classes/:na]

解决办法

我开始没加鉴权,使用的是application.yml是可以的,加了之后要将application.yml换成bootstrap.yml。

server:
    port: 8801

spring:
    application:
        name: zongdapao-order
    datasource:
        url: jdbc:mysql://localhost:3306/zzxmysql02?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
        username: root
        password: root
        driver-class-name: com.mysql.cj.jdbc.Driver
    cloud:
        nacos:
            discovery:
                server-addr: localhost:8848
                username: nacos
                password: nacos
                group: ZZX_GROUP
                namespace: d39a9ef0-bd56-4b6a-b8eb-44a2b85caf15
            config:
                server-addr: localhost:8848
                username: nacos
                password: nacos
                group: ZZX_GROUP
                namespace: d39a9ef0-bd56-4b6a-b8eb-44a2b85caf15
                file-extension: properties
#                shared-configs:
#                    - ${spring.application.name}-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
    profiles:
        active: dev
#  jta:
#    atomikos:
#      properties:
#        enable-logging: false

feign:
    hystrix:
        enabled: true

mybatis:
    mapper-locations:
        - classpath:dao/*.xml
        - classpath*:com/**/dao/*.xml

spring cloud Alibaba组件版本依赖关系
2021.x 分支
适配 Spring Boot 2.4,Spring Cloud 2021.x 版本及以上的 Spring Cloud Alibaba 版本按从新到旧排列如下表(最新版本用*标记):

Spring Cloud Alibaba Version Spring Cloud Version Spring Boot Version
2021.0.5.0* Spring Cloud 2021.0.5 2.6.13
2021.0.4.0 Spring Cloud 2021.0.4 2.6.11
2021.0.1.0 Spring Cloud 2021.0.1 2.6.3
2021.1 Spring Cloud 2020.0.1 2.4.2

2.2.x 分支
适配 Spring Boot 为 2.4,Spring Cloud Hoxton 版本及以下的 Spring Cloud Alibaba 版本按从新到旧排列如下表(最新版本用*标记):

Spring Cloud Alibaba Version Spring Cloud Version Spring Boot Version
2.2.10-RC1* Spring Cloud Hoxton.SR12 2.3.12.RELEASE
2.2.9.RELEASE Spring Cloud Hoxton.SR12 2.3.12.RELEASE
2.2.8.RELEASE Spring Cloud Hoxton.SR12 2.3.12.RELEASE
2.2.7.RELEASE Spring Cloud Hoxton.SR12 2.3.12.RELEASE
2.2.6.RELEASE Spring Cloud Hoxton.SR9 2.3.2.RELEASE
2.2.1.RELEASE Spring Cloud Hoxton.SR3 2.2.5.RELEASE
2.2.0.RELEASE Spring Cloud Hoxton.RELEASE 2.2.X.RELEASE
2.1.4.RELEASE Spring Cloud Greenwich.SR6 2.1.13.RELEASE
2.1.2.RELEASE Spring Cloud Greenwich 2.1.X.RELEASE
2.0.4.RELEASE(停止维护,建议升级) Spring Cloud Finchley 2.0.X.RELEASE
1.5.1.RELEASE(停止维护,建议升级) Spring Cloud Edgware 1.5.X.RELEASE

组件版本关系
每个 Spring Cloud Alibaba 版本及其自身所适配的各组件对应版本如下表所示(注意,Spring Cloud Dubbo 从 2021.0.1.0 起已被移除出主干,不再随主干演进):文章来源地址https://www.toymoban.com/news/detail-842557.html

Spring Cloud Alibaba Version Sentinel Version Nacos Version RocketMQ Version Dubbo Version Seata Version
2022.0.0.0 1.8.6 2.2.1 4.9.4 ~ 1.7.0
2022.0.0.0-RC2 1.8.6 2.2.1 4.9.4 ~ 1.7.0-native-rc2
2021.0.5.0 1.8.6 2.2.0 4.9.4 ~ 1.6.1
2.2.10-RC1 1.8.6 2.2.0 4.9.4 ~ 1.6.1
2022.0.0.0-RC1 1.8.6 2.2.1-RC 4.9.4 ~ 1.6.1
2.2.9.RELEASE 1.8.5 2.1.0 4.9.4 ~ 1.5.2
2021.0.4.0 1.8.5 2.0.4 4.9.4 ~ 1.5.2
2.2.8.RELEASE 1.8.4 2.1.0 4.9.3 ~ 1.5.1
2021.0.1.0 1.8.3 1.4.2 4.9.2 ~ 1.4.2
2.2.7.RELEASE 1.8.1 2.0.3 4.6.1 2.7.13 1.3.0
2.2.6.RELEASE 1.8.1 1.4.2 4.4.0 2.7.8 1.3.0
2021.1 or 2.2.5.RELEASE or 2.1.4.RELEASE or 2.0.4.RELEASE 1.8.0 1.4.1 4.4.0 2.7.8 1.3.0
2.2.3.RELEASE or 2.1.3.RELEASE or 2.0.3.RELEASE 1.8.0 1.3.3 4.4.0 2.7.8 1.3.0
2.2.1.RELEASE or 2.1.2.RELEASE or 2.0.2.RELEASE 1.7.1 1.2.1 4.4.0 2.7.6 1.2.0
2.2.0.RELEASE 1.7.1 1.1.4 4.4.0 2.7.4.1 1.0.0
2.1.1.RELEASE or 2.0.1.RELEASE or 1.5.1.RELEASE 1.7.0 1.1.4 4.4.0 2.7.3 0.9.0
2.1.0.RELEASE or 2.0.0.RELEASE or 1.5.0.RELEASE 1.6.3 1.1.1 4.4.0 2.7.3 0.7.1

到了这里,关于Nacos开启鉴权后读取不到配置文件,get data from Nacos error,dataId:http error, code=403,dataId=的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Docker 中安装Nacos 2.2.2 并开启鉴权

    1.打开终端或命令提示符,并输入以下命令下载最新版本的 Nacos 镜像: 2.创建容器存放地址/data/docker/nacos,并在该目录下启动Nacos容器: 3.运行命令,启动 Nacos 容器: 4.运行以下命令,检查 Nacos 容器是否正在运行: 5.访问 http://更换你的服务器IP:8848/nacos/ 页面检查是否正常打

    2024年02月15日
    浏览(33)
  • Nacos配置中心之引用不到配置文件问题

    一、Springboot中application.yml、application.properties和bootStrap.yml的加载顺序 1、SpringApplication位于项目根目录,所以所有得代码要和SpringApplication所在目录平级或下一级 2、以jar包发布springboot项目时,默认会先使用jar包跟目录下的application.properties来作为项目配置文件。 如果在不同的

    2024年02月07日
    浏览(26)
  • Nacos配置中心中配置文件的创建、微服务读取nacos配置中心

    在企业项目中会有非常多的服务,不同的开发环境还有不同的配置文件,所以就导致配置文件非常多。 那么肯定就会有一些公共配置,多个服务都是使用过一样的,那么就可以使用配置中心来进行统一管理,避免修改一个配置项要去各个服务都改一遍。 使用传统方式的配置

    2024年02月02日
    浏览(30)
  • Springboot读取外部配置文件,项目部署时配置读取不到问题

    需求: 最近项目部署,但是每个地方都有个别地方配置的差异,我们每次打包后再进行修改极度不方便,这里将有关的配置都抽取出来,放在jar包外进行配置,这样以后更新时只需要将jar包更换然后重启即可,配置读取外部的固定配置文件。 SpringBoot 配置 springboot默认配置的

    2024年02月07日
    浏览(39)
  • springboot读取多文件配置(包括nacos)

    首先来简单了解一下这个类。 ResourceBundle类主要是用来 解决国际化和本地化问题 ,就我的理解,就是类似于前端界面的字体显示,国际化操作一般都要支持多国语言,那么这个ResourceBundle类就能够简单快速的解决这个问题。 同时,这个类只能支持读取properties属性文件,和

    2023年04月09日
    浏览(34)
  • SpringCloud nacos1.x.x版本升级到2.2.3版本并开启鉴权踩坑

    近期由于服务器漏洞扫描,检测出nacos存在绕过登录鉴权漏洞,如图 需要进行升级并开启鉴权,就此次升级做下记录。 1.首先备份原来的nacos,导出配置文件作为备份; 2,从官网下载nacos-server-2.2.3.zip,上传服务器并解压,修改application.properties,如图 修改后sh startup.sh -m sta

    2024年02月03日
    浏览(35)
  • Spring Boot @Value读不到Nacos配置中心的值。(properties配置文件)

    读不到配置中心的值, 配置中心的配置文件名字(Data ID的值)要以.properties结尾。 如果是yaml,就以yaml命名。

    2024年02月07日
    浏览(41)
  • SpringCloud-SpringBoot读取Nacos上的配置文件

    在 Spring Boot 应用程序中,可以使用 Spring Cloud Nacos 来实现从 Nacos 服务注册中心和配置中心读取配置信息。以下是如何在 Spring Boot 中读取 Nacos 上的配置文件的步骤: 1. 引入依赖 首先,在 Spring Boot 项目的 pom.xml 文件中添加 Spring Cloud Nacos 的依赖: 2. 配置 Nacos 连接信息 将 Nac

    2024年04月17日
    浏览(42)
  • Nacos鉴权和配置加密—官方原版

    按照官方文档配置启动,默认是不需要登录的,这样会导致配置中心对外直接暴露。而启用鉴权之后,需要在使用用户名和密码登录之后,才能正常使用nacos。开启鉴权之前,application.properties中的配置信息为: 开启鉴权之后,application.properties中的配置信息为: 开启鉴权之后,

    2024年02月05日
    浏览(29)
  • springboot读取Nacos配置文件失败,报Could not resolve placeholder ‘xxx’ in value ‘${xxx}’

    在使用@Value注解去获取nacos配置文件时,启动服务报错,报Could not resolve placeholder ‘xxx’ in value ‘${xxx}’ 一班出现这个问题需要排查以下几点: 1.@Value注解内是否有拼写错误 2.nacos相关配置是否写入bootstrap.yml文件 3.nacos配置文件所在命名空间是否与bootstrap.yml文件内所声明的命

    2024年02月05日
    浏览(40)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包