搜索了一些类似案例未解决,问题出在哪里?
1.> 错误提示:
Failed to bind properties under 'mapper' to tk.mybatis.mapper.entity.Config:
Reason: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [tk.mybatis.mapper.entity.Config]
Action:
Update your application's configuration
- pom.xml ,重点关注 “tk.mybatis”
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.12</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>cn.shq</groupId>
<artifactId>springBoot_CRUD</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springBoot_CRUD</name>
<description>springBoot_CRUD</description>
<properties>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- mybatis-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.0</version>
</dependency>
<!-- 前端开发者工具 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<!-- mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.25</version>
</dependency>
<!-- lombok插件-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- 测试-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- 前端开始-->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>layui</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap-select</artifactId>
<version>1.13.17</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap-datetimepicker</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap-table</artifactId>
<version>1.16.0</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>momentjs</artifactId>
<version>2.24.0</version>
</dependency>
<!-- 前端结束-->
<!-- lang包的增强版 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
</dependencies>
<build>
<!-- 使得程序在执行过程中,能够解析到各个mapper.xml文件 。
否则target目录下没有对应的mapper文件,程序不能正常执行。 -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.css</include>
<include>**/*.js</include>
<include>**/*.html</include>
<include>**/*.png</include>
<include>**/*.jpg</include>
<include>**/*.properties</include>
<include>**/*.yml</include>
<include>**/*.xml</include>
<include>**/*.conf</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
- application.properties
# \u670D\u52A1\u5668\u8BBE\u7F6E\uFF1A \u7AEF\u53E3\u53F7\u548C\u8BBF\u95EE\u8DEF\u5F84
server:
port: 8088
servlet:
context-path: /shq
# \u6570\u636E\u6E90\u8BBE\u7F6E
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.31.226:3306/dhc_crud??serverTimezone=UTC
username: root
password: 123456
thymeleaf:
cache: false
suffix: .html
web:
resources:
static-locations: classpath:/templates/,classpath:/static/image/
# \u8BA9\u63A7\u5236\u53F0\u663E\u793A\u6267\u884C\u7684SQL\u8BED\u53E5
logging:
level:
cn:
shq:
mapper: debug
# mybatis\u914D\u7F6E
mybatis:
type-aliases-package: cn.shq.model # \u522B\u540D
configuration:
auto-mapping-behavior: full #\u8BBE\u7F6E\u5168\u81EA\u52A8\u6620\u5C04
use-column-label: true # \u5217\u6807\u7B7E\u4EE3\u66FF\u5B57\u6BB5\u540D
#\u8BBE\u7F6Emapper\u7684\u8DEF\u5F84
mapper-locations: classpath:cn/shq/mapper/*.xml