项目场景:

nacos创建命名空间后,为了方便,直接去表里改了tenant_id,ruoyi-system模块启动时报
Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ruoyi.system.mapper.SysConfigMapper.selectConfigList


问题描述

`` ruoyi-system启动时报错,Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ruoyi.system.mapper.SysConfigMapper.selectConfigList,这是因为找不到master数据源

bootstrap.yml配置

# Tomcat
server:
  port: 9201

# Spring
spring: 
  application:
    # 应用名称
    name: ruoyi-system
  profiles:
    # TODO 1 环境配置
    active: @spring.profile@
  cloud:
    nacos:
      discovery:
        #TODO  服务注册地址
        server-addr: @nacos.server.address@
      config:
        # TODO配置中心地址
        server-addr: @nacos.server.address@
        # 配置文件格式
        file-extension: yml
        # 共享配置
        shared-configs:
          - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
        namespace: @nacos.server.namespace@
    sentinel:
     #取消控制台懒加载
     eager: true
     transport:
       dashboard: @sentinel.dashboard.address@

pom.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>com.ruoyi</groupId>
        <artifactId>ruoyi-modules</artifactId>
        <version>3.4.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
	
    <artifactId>ruoyi-modules-system</artifactId>


    <profiles>
        <profile>
            <!-- 本地环境 -->
            <id>dev</id>
            <properties>
                <spring.profile>dev</spring.profile>
                <nacos.server.address>127.0.0.1:8848</nacos.server.address>
                <nacos.server.namespace>dev</nacos.server.namespace>
                <sentinel.dashboard.address>127.0.0.1:3377</sentinel.dashboard.address>
            </properties>
            <activation>
                <!-- 是否默认激活 -->
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>      
    </profiles>

    <description>
        ruoyi-modules-system系统模块
    </description>
	

    <build>
        <finalName>${project.artifactId}</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <!--开启过滤,用指定的参数替换directory下的文件中的参数-->
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
   
</project>

---

# 原因分析:
  `` ruoyi-system启动时报错,Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ruoyi.system.mapper.SysConfigMapper.selectConfigList,这是因为找不到master数据源,而master数据源 又是在nacos中的配置yml文件中配置,所以分析时读取不到nacos配置文件。但是以前时可以读取到的,但是改了直接在表里改了命名空间之后就不可以了,将配置文件从nacos中复制到resources文件下,改名为application-dev.yml,数据源配置成功,所以不是配置文件本身的问题,是读取的问题。

---

# 解决方案:
  在nacos控制台重新发布配置文件。



Logo

快速构建 Web 应用程序

更多推荐