是3.3.0 升级 3.3.1后出现的问题,之前运行正常
这边是将nacos部署在局域网的k8s中,mysql在局域网的一个linux系统中,test部署在k8s中,我本机dev正常连接局域网的nacos,mysql,服务也注册成功,但是在test环境下就显示mysql连接失败
10:13:06.658 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Found key 'spring.profiles.active' in PropertySource 'commandLineArgs' with value of type String 210:13:06.719 [main] DEBUG org.springframework.core.env.StandardEnvironment - Activating profiles [test] 3----启动中,读取到的环境变量:[test],jar地址:[file:/blade/log/app.jar]---- 42023-12-27 10:13:12.140 INFO 1 --- [kground-preinit] o.h.validator.internal.util.Version : HV000001: Hibernate Validator 6.2.5.Final 5______ _ _ ___ ___ 6| ___ \| | | | \ \ / / 7| |_/ /| | __ _ __| | ___ \ V / 8| ___ \| | / _` | / _` | / _ \ > < 9| |_/ /| || (_| || (_| || __/ / . \ 10\____/ |_| \__,_| \__,_| \___|/__/ \__\ 11 12:: BladeX 3.3.1.RELEASE :: blade-log:test :: Running SpringBoot 2.7.18 :: 13 142023-12-27 10:13:18.721 WARN 1 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[blade.yaml] & group[DEFAULT_GROUP] 152023-12-27 10:13:19.129 WARN 1 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[blade-test.yaml] & group[DEFAULT_GROUP] 162023-12-27 10:13:19.536 WARN 1 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[blade-log] & group[DEFAULT_GROUP] 172023-12-27 10:13:19.946 WARN 1 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[blade-log.yaml] & group[DEFAULT_GROUP] 182023-12-27 10:13:20.354 WARN 1 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[blade-log-test.yaml] & group[DEFAULT_GROUP] 192023-12-27 10:13:20.358 INFO 1 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-blade-log-test.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-blade-log.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-blade-log,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-blade-test.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-blade.yaml,DEFAULT_GROUP'}] 202023-12-27 10:13:20.598 INFO 1 --- [ main] org.springblade.core.log.LogApplication : The following 1 profile is active: "test" 212023-12-27 10:13:26.522 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode 222023-12-27 10:13:26.534 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode. 232023-12-27 10:13:26.631 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 39 ms. Found 0 Redis repository interfaces. 242023-12-27 10:13:27.308 WARN 1 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[org.springblade.core.log]' package. Please check your configuration. 252023-12-27 10:13:27.735 INFO 1 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=34ffe955-b404-329f-a25d-59a9e6cdc43d 262023-12-27 10:13:27.744 INFO 1 --- [ main] s.c.l.p.BladePropertySourcePostProcessor : BladePropertySourcePostProcessor init. 272023-12-27 10:13:28.072 INFO 1 --- [ main] s.c.l.p.BladePropertySourcePostProcessor : BladePropertySourcePostProcessor process @BladePropertySource bean. 282023-12-27 10:13:32.854 WARN 1 --- [ main] io.undertow.websockets.jsr : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used 292023-12-27 10:13:32.949 INFO 1 --- [ main] io.undertow.servlet : Initializing Spring embedded WebApplicationContext 302023-12-27 10:13:32.950 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 12257 ms 312023-12-27 10:13:33.793 INFO 1 --- [ main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource 322023-12-27 10:13:36.225 ERROR 1 --- [ main] com.alibaba.druid.pool.DruidDataSource : init datasource error, url: ${blade.datasource.test.url} 33 34java.sql.SQLException: connect error, url ${blade.datasource.test.url}, driverClass com.mysql.cj.jdbc.Driver
connect error, url ${blade.datasource.test.url}, driverClass com.mysql.cj.jdbc.Driver 是没有获取到nacos中的url配置?麻烦给指个方向到哪去调试。
先排除掉k8s环境影响。本地直连部署nacos,用docker或者源码启动均可。看下本地环境是否能在test注册成功,3.3.1增加了nacos的认证模式,如果nacos账号密码是nacos、nacos则不用改动,否则需要修改,具体见:https://center.javablade.com/blade/BladeX-Doc/src/branch/master/%E7%AC%AC1%E7%AB%A0%20%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B/1.5%20%E5%B7%A5%E7%A8%8B%E8%BF%90%E8%A1%8C/1.5.1%20%E8%BF%90%E8%A1%8CCloud%E7%89%88%E6%9C%AC.md#%E5%90%AF%E5%8A%A8%E5%87%86%E5%A4%87
你的这个错,是没读取到nacos配置,而gateway不需要数据库,所以就算读取不到也能启动成功。
这个问题的排查思路见:https://sns.bladex.cn/q-41.html
扫一扫访问 Blade技术社区 移动端