开发者社区 > 云原生 > 正文

spring cloud gateway sentinel 持久化规则到nacos 启动报错 Err

spring cloud gateway sentinel 持久化规则到nacos 启动报错 环境: nacos:1.3.0,sentinel:1.7.2 springboot 2.3.3 spring cloud Hoxton.SR5 cloud-alibaba:2.2.2.RELEASEJDK1.8 整合spring-cloud-starter-alibaba-sentinel,sentinel-datasource-nacos 启动报错: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ds-sentinel-nacos-datasource': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException

bootstrap.yml: spring sentinel: transport: dashboard: 10.254.246.36:8080 eager: true datasource: ds: nacos: server-addr: 10.254.246.34:8848 group-id: DEFAULT_GROUP data-id: ${spring.application.name}-${spring.profiles.active}-sentinel rule-type: flow

原提问者GitHub用户haoboy78

展开
收起
学习娃 2023-05-19 15:45:29 250 0
1 条回答
写回答
取消 提交回答
  • 我以前也有和你一样的问题。您需要设置ds.nacos.username和ds.nacos.密码。 像这样:

      datasource:
        ds: 
          nacos:
            server-addr: xxx
            username: nacos
            password: nacos
    

    错误堆栈

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ds1-sentinel-nacos-datasource': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:178) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:101) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1821) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1266) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at com.alibaba.cloud.sentinel.custom.SentinelDataSourceHandler.registerBean(SentinelDataSourceHandler.java:203) ~[spring-cloud-starter-alibaba-sentinel-2.2.2.RELEASE.jar:2.2.2.RELEASE] at com.alibaba.cloud.sentinel.custom.SentinelDataSourceHandler.lambda$afterSingletonsInstantiated$0(SentinelDataSourceHandler.java:93) ~[spring-cloud-starter-alibaba-sentinel-2.2.2.RELEASE.jar:2.2.2.RELEASE] at java.util.TreeMap.forEach(TreeMap.java:1005) [?:1.8.0_191] at com.alibaba.cloud.sentinel.custom.SentinelDataSourceHandler.afterSingletonsInstantiated(SentinelDataSourceHandler.java:80) [spring-cloud-starter-alibaba-sentinel-2.2.2.RELEASE.jar:2.2.2.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:912) [spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) [spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) [spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) [spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE] at com.che300.gamma.Application.main(Application.java:25) [classes/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.2.7.RELEASE.jar:2.2.7.RELEASE] Caused by: java.lang.NullPointerException at java.util.Hashtable.put(Hashtable.java:460) ~[?:1.8.0_191] at java.util.Properties.setProperty(Properties.java:166) ~[?:1.8.0_191] at com.alibaba.cloud.sentinel.datasource.factorybean.NacosDataSourceFactoryBean.getObject(NacosDataSourceFactoryBean.java:70) ~[spring-cloud-alibaba-sentinel-datasource-2.2.2.RELEASE.jar:2.2.2.RELEASE] at com.alibaba.cloud.sentinel.datasource.factorybean.NacosDataSourceFactoryBean.getObject(NacosDataSourceFactoryBean.java:34) ~[spring-cloud-alibaba-sentinel-datasource-2.2.2.RELEASE.jar:2.2.2.RELEASE] at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:171) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] ... 24 more

    原回答者GitHub用户boailiu

    2023-05-19 20:48:28
    赞同 展开评论 打赏

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关电子书

更多
阿里云容器 AHAS Sentinel 网关流控揭秘 立即下载
workshop专场-微服务专场-开发者动手实践营-微服务-使用Sentinel进行微服务流量控制 立即下载
Sentinel分布式系统下的流量防卫兵 立即下载