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&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><outputDir>${configuration.outputDir}
</outputDir><fileOverride>true
</fileOverride><enableCache>true
</enableCache><author>ZuoQuan Tu
</author><activeRecord>false
</activeRecord><dataSource><driverName>com.mysql.jdbc.Driver
</driverName><url>${dataSource.url}
</url><username>${dataSource.username}
</username><password>${dataSource.password}
</password></dataSource><strategy><naming>underline_to_camel
</naming><idGenType>uuid
</idGenType></strategy><packageInfo><parent>${packageInfo.parent}
</parent><service>service
</service><serviceImpl>service.impl
</serviceImpl><entity>entity
</entity><mapper>mapper
</mapper><xml>mapper
</xml></packageInfo><template></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的方式。的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。