我是靠谱客的博主 干净芒果,最近开发中收集的这篇文章主要介绍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.设置成功且无误后,会出现这个:
点击绿色运行标识符
控制台输出如下信息:
"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 搭建 springMVC+mybatis+maven 项目(三)mybatis-generater自动生成MyBatis代码所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复