1、复制mybatis配置文件到resource文件夹下
mybatis-config.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>
<typeAliases>
<typeAlias alias="sqladapter" type="com.example.filedemo.controller.SQLAdapter" />
</typeAliases>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/newbee_mall_db?serverTimezone=GMT"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="Mapper.xml"/>
</mappers>
</configuration>
2、复制mapper文件到resources文件夹下
Mapper.xml 文件内容
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="mobile">
<select id="superSelect" parameterType="String" resultType="java.util.LinkedHashMap">
${sql}
</select>
</mapper>
3、添加jar包到编译路径
4、注意以下框中路径要一致
5、SQLAdapter.java文件内容
package com.example.filedemo.controller;
public class SQLAdapter {
String sql;
public SQLAdapter(String sql) {
this.sql = sql;
}
public String getSql() {
return sql;
}
public void setSql(String sql) {
this.sql = sql;
}
}
6、资源查看
https://download.csdn.net/download/guoruijun_2012_4/12689874