企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
在`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> ```