全局配置
<?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>
<properties >
<property name="username" value="root"/>
<property name="password" value="123456"/>
</properties>
<typeAliases>
<package name="mybatis01.pojo"/>
</typeAliases>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/java2022"/>
<property name="username" value="${username}"/>
<property name="password" value="${password}"/>
</dataSource>
</environment>
</environments>
<mappers>
<!--<mapper resource="org/mybatis/example/BlogMapper.xml"/>-->
<mapper resource="mapper/tulunMapper.xml"></mapper>
<mapper resource="mapper/newsMapper.xml"/>
<!--<mapper class="com.tulun.Mybatis.mapper.userMapper"></mapper>-->
</mappers>
</configuration>
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="mybatis01.mapper.tulunMapper">
<select id="selectByid" parameterType="int" resultType="mybatis01.pojo.tulun">
select * from tulun where id = #{sid}
</select>
</mapper>
记录