我是靠谱客的博主 干净芒果,这篇文章主要介绍idea 搭建 springMVC+mybatis+maven 项目(三)mybatis-generater自动生成MyBatis代码,现在分享给大家,希望可以做个参考。

1.笔者在自己电脑本地创建数据库如下表:
这里写图片描述
这里拿t_user为例来进行搭建,包括(二)的generatorConfig.xml中的数据库表的t_user是与之对应的。
2.下面回到idea项目中来,点击菜单Run->Edit configration 在command line输入mybatis-generator:generate -e
点击Apply或者直接OK
这里写图片描述
其中Name可选择默认或自己重新命名。
3.设置成功且无误后,会出现这个:
这里写图片描述
点击绿色运行标识符
控制台输出如下信息:

复制代码
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
"C:Program FilesJavajdk1.7.0_80binjava" -Dmaven.multiModuleProjectDirectory=D:workspacetravel -Dmaven.home=E:apache-maven-3.3.9 -Dclassworlds.conf=E:apache-maven-3.3.9binm2.conf -Didea.launcher.port=7532 "-Didea.launcher.bin.path=E:workSoftwareIntelliJ IDEA 2016.2.1bin" -Dfile.encoding=UTF-8 -classpath "E:apache-maven-3.3.9bootplexus-classworlds-2.5.2.jar;E:workSoftwareIntelliJ IDEA 2016.2.1libidea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=2016.2.1 -s E:apache-maven-3.3.9confsettings.xml mybatis-generator:generate -e [INFO] Error stacktraces are turned on. [WARNING] [WARNING] Some problems were encountered while building the effective settings [WARNING] expected START_TAG or END_TAG not TEXT (position: TEXT seen ... artifacts.rn |rn | Default: ${user.home}/.m2/repositoryrn <l... @53:5) @ E:apache-maven-3.3.9confsettings.xml, line 53, column 5 [WARNING] expected START_TAG or END_TAG not TEXT (position: TEXT seen ... artifacts.rn |rn | Default: ${user.home}/.m2/repositoryrn <l... @53:5) @ E:apache-maven-3.3.9confsettings.xml, line 53, column 5 [WARNING] [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building travel Maven Webapp 3.8.1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- mybatis-generator-maven-plugin:1.3.2:generate (default-cli) @ junit --- [INFO] Connecting to the Database [INFO] Introspecting table t_user log4j:WARN No appenders could be found for logger (org.mybatis.generator.internal.db.DatabaseIntrospector). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. [INFO] Generating Example class for table t_user [INFO] Generating Record class for table t_user [INFO] Generating Mapper Interface for table t_user [INFO] Generating SQL Map for table t_user [INFO] Saving file TUserMapper.xml [INFO] Saving file TUserExample.java [INFO] Saving file TUser.java [INFO] Saving file TUserMapper.java [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.950 s [INFO] Finished at: 2016-11-26T11:28:42+08:00 [INFO] Final Memory: 10M/154M [INFO] ------------------------------------------------------------------------ Process finished with exit code 0

图片:
这里写图片描述

有警告,可能是笔者的日志信息配置有问题,目前还未找到解决方案,待解之后,定会分享给大家~
4.好了,看一下自己的项目包中是不是多了几个文件,great!
这里写图片描述
自动生成代码成功~吃饭去咯~

最后

以上就是干净芒果最近收集整理的关于idea 搭建 springMVC+mybatis+maven 项目(三)mybatis-generater自动生成MyBatis代码的全部内容,更多相关idea内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(60)

评论列表共有 0 条评论

立即
投稿
返回
顶部