日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

MyBatis-Plus之通过插件将数据库表生成Entiry,Mapper.xml,Mapper.class的方式。

發布時間:2024/9/27 数据库 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MyBatis-Plus之通过插件将数据库表生成Entiry,Mapper.xml,Mapper.class的方式。 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、參考網址:http://mp.baomidou.com/#/generate-code
2、創建maven項目,修改pom.xml文件,如下:

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>com.xxxx</groupId><artifactId>parent-pom</artifactId><version>1.0.0-SNAPSHOT</version></parent><groupId>com.xxxx</groupId><artifactId>mapper-creator</artifactId><version>1.0-SNAPSHOT</version><properties><configuration.outputDir>d:\demo-mapper-folder</configuration.outputDir><dataSource.url>jdbc:mysql://192.168.18.140:8066/TESTDB?useUnicode=true&amp;characterEncoding=UTF-8</dataSource.url><dataSource.username>root</dataSource.username><dataSource.password>123456</dataSource.password><packageInfo.parent>com.xxxx.demotwo</packageInfo.parent></properties><build><plugins><plugin><groupId>com.baomidou</groupId><artifactId>mybatisplus-maven-plugin</artifactId><version>1.0</version><configuration><!-- 輸出目錄(默認java.io.tmpdir) --><outputDir>${configuration.outputDir}</outputDir><!-- 是否覆蓋同名文件(默認false) --><fileOverride>true</fileOverride><!-- mapper.xml 中添加二級緩存配置(默認true) --><enableCache>true</enableCache><!-- 開發者名稱 --><author>ZuoQuan Tu</author><!-- 是否開啟 ActiveRecord 模式(默認true) --><activeRecord>false</activeRecord><!-- 數據源配置,( **必配** ) --><dataSource><driverName>com.mysql.jdbc.Driver</driverName><url>${dataSource.url}</url><username>${dataSource.username}</username><password>${dataSource.password}</password></dataSource><strategy><!-- 字段生成策略,四種類型,從名稱就能看出來含義:nochange(默認),underline_to_camel,(下劃線轉駝峰)remove_prefix,(去除第一個下劃線的前部分,后面保持不變)remove_prefix_and_camel(去除第一個下劃線的前部分,后面轉駝峰) --><naming>underline_to_camel</naming><!-- 表前綴 --><!--<tablePrefix>bmd_</tablePrefix>--><!--Entity中的ID生成策略(默認 id_worker)--><idGenType>uuid</idGenType><!--自定義超類--><!--<superServiceClass>com.baomidou.base.BaseService</superServiceClass>--><!-- 要包含的表 與exclude 二選一配置--><!--<include>--><!--<property>sec_user</property>--><!--<property>table1</property>--><!--</include>--><!-- 要排除的表 --><!--<exclude>--><!--<property>schema_version</property>--><!--</exclude>--></strategy><packageInfo><!-- 父級包名稱,如果不寫,下面的service等就需要寫全包名(默認com.baomidou) --><parent>${packageInfo.parent}</parent><!--service包名(默認service)--><service>service</service><!--serviceImpl包名(默認service.impl)--><serviceImpl>service.impl</serviceImpl><!--entity包名(默認entity)--><entity>entity</entity><!--mapper包名(默認mapper)--><mapper>mapper</mapper><!--xml包名(默認mapper.xml)--><xml>mapper</xml></packageInfo><template><!-- 定義controller模板的路徑 --><!--<controller>/template/controller1.java.vm</controller>--></template></configuration><dependencies><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>${mysql.version}</version></dependency></dependencies></plugin></plugins></build> </project>

3、項目運行步驟
A、修改pom.xml中的properties中的各各參數的值,以適應自己項目中的配置
B、在maven的setting.xml中添加:

<pluginGroups><pluginGroup>com.baomidou</pluginGroup> </pluginGroups>

C、執行以下maven命令:
mvn mp:code

執行完成之后,即可看到彈出一個文件夾,里面包含了要生成的表的Entity,mapper,mapper.xml等

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的MyBatis-Plus之通过插件将数据库表生成Entiry,Mapper.xml,Mapper.class的方式。的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。