在`MyBatis入门`的基础上,做以下修改:
1. 删除`resources/com/gosuncn/dao/UserDaoMapper.xml`文件
2. 修改`com.gosuncn.dao.UserDao`文件
```java
package com.gosuncn.dao;
import com.gosuncn.entity.User;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface UserDao {
@Select("SELECT `id`, `name`, `age`, `address` FROM `user`")
List<User> findAll();
}
```
3. 修改`resources/SqlMapConfig.xml`文件
```xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<environments default="dev">
<environment id="dev">
<transactionManager type="JDBC"></transactionManager>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/mybatis"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper class="com.gosuncn.dao.UserDao"/>
</mappers>
</configuration>
```
- springboot使用mybatis
- MyBatis入门
- MyBatis注解方式
- 从零开始MyBatis保存操作
- MyBatis更新操作
- MyBatis删除操作
- MyBatis根据Id查询用户
- MyBatis根据名称模糊查询用户1
- MyBatis根据名称模糊查询用户2
- MyBatis查询总记录条数
- MyBatis获取插入时自增的Id
- MyBatis传参类型
- MyBatis返回值字段不匹配
- MyBatis之properties标签
- MyBatis类型别名typeAliases
- mybatis逆向工程maven之pom配置
- configurationFile
- verbose
- overwrite
- includeCompileDependencies
- includeAllDependencies
- maven之pom配置总结版
- 逆向工程generatorConfig配置