您的位置:首页 > 编程语言 > Java开发

idea 搭建 springMVC+mybatis+maven 项目(三)mybatis-generater自动生成MyBatis代码

2016-11-26 11:34 1176 查看
1.笔者在自己电脑本地创建数据库如下表:



这里拿t_user为例来进行搭建,包括(二)的generatorConfig.xml中的数据库表的t_user是与之对应的。

2.下面回到idea项目中来,点击菜单Run->Edit configration 在command line输入mybatis-generator:generate -e

点击Apply或者直接OK



其中Name可选择默认或自己重新命名。

3.设置成功且无误后,会出现这个:



点击绿色运行标识符

控制台输出如下信息:

"C:\Program Files\Java\jdk1.7.0_80\bin\java" -Dmaven.multiModuleProjectDirectory=D:\workspace\travel -Dmaven.home=E:\apache-maven-3.3.9 -Dclassworlds.conf=E:\apache-maven-3.3.9\bin\m2.conf -Didea.launcher.port=7532 "-Didea.launcher.bin.path=E:\workSoftware\IntelliJ IDEA 2016.2.1\bin" -Dfile.encoding=UTF-8 -classpath "E:\apache-maven-3.3.9\boot\plexus-classworlds-2.5.2.jar;E:\workSoftware\IntelliJ IDEA 2016.2.1\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=2016.2.1 -s E:\apache-maven-3.3.9\conf\settings.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.\r\n   |\r\n   | Default: ${user.home}/.m2/repository\r\n  <l... @53:5)  @ E:\apache-maven-3.3.9\conf\settings.xml, line 53, column 5
[WARNING] expected START_TAG or END_TAG not TEXT (position: TEXT seen ... artifacts.\r\n   |\r\n   | Default: ${user.home}/.m2/repository\r\n  <l... @53:5)  @ E:\apache-maven-3.3.9\conf\settings.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 spring mvc mybatis