MybatisPlus------MyBatisX插件(十二)
MyBatisX插件是IDEA插件,如果想要使用它,那么首先需要在IDEA中進行安裝。
安裝插件
搜索"MyBatisX",點擊Install,之后重啟IDEA即可。
插件基本用途:接口與xml文件跳轉
之后就可以在Mapper接口中,看到紅色小鳥的標識,點擊這個紅色小鳥,會自動找到對應mapper.xml文件,以及文件中的方法??梢哉f十分方便。
在mapper.xml文件中也會有藍色小鳥,點擊后會自動跳轉到mapper接口的位置。
插件:快速生成代碼
首先需要在IDEA中連接到數(shù)據(jù)庫
點擊數(shù)據(jù)庫,點擊對應的表名,點擊“MybatisX-Generator”
之后填寫對應的內容
之后是配置生成mapper文件,service文件的位置。
選中Lombok就不用再選toString/hashCode/equals
之后點擊finish即可。
快速生成CRUD
不需要寫返回值,只需要寫方法名就能夠快速生成CRUD
選擇之后需要點擊“Alt+Enter”才能夠生效。
選擇Generate Mybatis Sql,即可在mapper文件中自動生成sql。
測試delete
int deleteByNumAndProductCode(@Param("num") Integer num, @Param("productCode") String productCode);
<delete id="deleteByNumAndProductCode">
delete
from aaaaa
where num = #{num,jdbcType=NUMERIC}
AND product_code = #{productCode,jdbcType=VARCHAR}
</delete>
測試update
int updateProductCodeByNumAndProductCode(@Param("productCode") String productCode, @Param("num") Integer num, @Param("oldProductCode") String oldProductCode);
注意update方法名的語法,要有By加條件。
<update id="updateProductCodeByNumAndProductCode">
update aaaaa
set product_code = #{productCode,jdbcType=VARCHAR}
where num = #{num,jdbcType=NUMERIC}
AND product_code = #{oldProductCode,jdbcType=VARCHAR}
</update>
select、query 查找
update 更新
delete刪除
by 條件
and 連接條件文章來源:http://www.zghlxwxcb.cn/news/detail-442590.html
太牛皮了,我敲文章來源地址http://www.zghlxwxcb.cn/news/detail-442590.html
到了這里,關于MybatisPlus------MyBatisX插件:快速生成代碼以及快速生成CRUD(十二)的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!