創建maven項目,修改pom.xml文件,如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
<?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> <!-- 輸出目錄(默認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> |
項目運行步驟
a、修改pom.xml中的properties中的各各參數的值,以適應自己項目中的配置
b、在maven的setting.xml中添加:
1
2
3
|
<plugingroups> <plugingroup>com.baomidou</plugingroup> </plugingroups> |
c、執行以下maven命令:
mvn mp:code
執行完成之后,即可看到彈出一個文件夾,里面包含了要生成的表的entity,mapper,mapper.xml等
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對服務器之家的支持。如果你想了解更多相關內容請查看下面相關鏈接
原文鏈接:https://blog.csdn.net/tototuzuoquan/article/details/80374881