Royi-cloud启动服务报错Invalid bound statement (not found): com.rk.system.mapper.SysConfigMapper.selectConf

问题

今天在用Royi-cloud写自己的微服务项目时,启动系统服务的时候一直报错:Invalid bound statement (not found): com.rk.system.mapper.SysConfigMapper.selectConfig,并且最下面还有几句话:

[Thread-1] WARN c.a.n.c.h.HttpClientBeanHolder - [shutdown,108] - [HttpClientBeanHolder] Start destroying common HttpClient
11:45:23.456 [Thread-5] WARN c.a.n.c.n.NotifyCenter - [shutdown,136] - [NotifyCenter] Start destroying Publisher
11:45:23.456 [Thread-5] WARN c.a.n.c.n.NotifyCenter - [shutdown,153] - [NotifyCenter] Destruction of the end
11:45:23.456 [Thread-1] WARN c.a.n.c.h.HttpClientBeanHolder - [shutdown,114] - [HttpClientBeanHolder] Destruction of the end

在这里插入图片描述

原因

出现这个问题的原因是服务没有读取到nacos上面的配置文件,我们看一下配置文件bootstrap.yml中的配置是否有问题。

如果配置没有问题的话,可能使用的nacos版本太高了,nacos 版本 2.x.x 以上会存在一些问题,我们需要在maven中引入一个依赖:

<!--新版本nacos需要bootstrap依赖,否则拿不到配置-->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-bootstrap</artifactId>
                <version>${bootstrap.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

引入这个以来后一般都能成功运行了。

问题2

在引用公共模块的时候,如果出现一个问题是:

Field redisService in com.rk.gateway.service.impl.ValidateCodeServiceImpl required a bean of type ‘com.rk.common.redis.service.RedisService’ that could not be found.

我们可以在启动类上添加:

@ComponentScan(basePackages = {"com.rk.common.redis.service"})

位置是该公共功能类所在的包。

posted @ 2023-03-03 11:56  爱吃雪糕的小布丁  阅读(39)  评论(0编辑  收藏  举报  来源