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>
<!-- 设置驼峰表示法-->
<!--
<settings>
<setting name="mapUnderscoreToCamelCase" value="true" />
</settings>
-->
<typeAliases>
<!-- 批量导入基本类别名 -->
<package name="nuczmfspringboot.sb_book20211007.entily"/>
</typeAliases>
</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="nuczmfspringboot.sb_book20211007.Dao.IUBookDao">//dao层的地址
//查询
<select id="allubookbybuid" parameterType="int" resultType="nuczmfspringboot.sb_book20211007.entily.UBook">/*id方法名,parameterType参数类型,resulType返回类型*/
select * from ubook where buid = #{buid}
</select>
//插入,没有返回
<insert id="addubook" parameterType="nuczmfspringboot.sb_book20211007.entily.UBook">
insert into ubook value (null,#{bname},#{blei},#{bpice},#{bshu},#{bfengmain},#{buid},#{bstate},#{bdata} )
</insert>
//删除,有参数,没有返回
<delete id="ubookdelete">
delete from ubook where buid = #{uid} and bid = #{bid}
</delete>
//修改,同样有参数,没有返回
<update id="ubookupdata">
update ubook set bstate = #{bstate} ,bdata = #{bdata} where buid = #{uid} and bid = #{bid}
</update>
//修改,插入,删除可以默认返回booleam
</mapper>
如果方法有多个参数可以不写parameterType,但是在dao层的方法加上
@Param
public boolean ubookdelete(@Param("uid") int uid,@Param("bid") int bid);
/**
转载自老师发的文件,(●ˇ∀ˇ●)
没有链接,感谢老师!
*/