maven web项目下mybatis generator的使用
idea中新建maven web项目,完善java,resources目录:

pom.xml中添加jdbc依赖,mybatis generator的依赖和插件:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency> <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.17</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-core -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.7</version>
</dependency> </dependencies> <build>
<plugins>
<plugin>
<!-- https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-maven-plugin -->
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.7</version>
</plugin>
</plugins>
</build>
resources目录下创建mybatis generator的配置文件generatorConfig.xml(mybatis generator配置文件默认名),内容大致如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> <generatorConfiguration> <classPathEntry location="/Users/yanguobin/.m2/repository/mysql/mysql-connector-java/8.0.17/mysql-connector-java-8.0.17.jar"/> <context id="mygenerator"> <jdbcConnection
driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/mybatisgeneratordemodb"
userId="root"
password="123"> <!-- 避免同时生成 *Example类 -->
<property name="nullCatalogMeansCurrent" value="true"></property> </jdbcConnection> <!-- 包名不存在时会自动生成 -->
<javaModelGenerator targetPackage="com.yanguobin.pojo" targetProject="src/main/java"></javaModelGenerator> <sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources"></sqlMapGenerator> <javaClientGenerator type="XMLMAPPER" targetPackage="com.yanguobin.dao" targetProject="src/main/java"></javaClientGenerator> <!-- enable* 属性设为false,避免把其他数据库下的同名表也给生成下来 -->
<table tableName="book" domainObjectName="Book" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false" selectByPrimaryKeyQueryId="false"></table>
</context> </generatorConfiguration>
数据表book:

点击Add Configuration...

点击+Maven

在Command line:下输入mybatis-generator:generate -e

点击绿色三角运行,同时观察Project栏目录文件变化情况


maven web项目下mybatis generator的使用的更多相关文章
- Maven插件方式使用Mybatis Generator
Mybatis Generator Mybatis Generator简称MBG,可以根据数据库自动生成实体类.单表查询接口及其映射xml文件(也可以选择以注解方式生成). 下面介绍一下以maven插 ...
- 做了一个web版的 MyBatis Generator
mybatis 官方提供了 MyBatis Generator ,可以通过 xml 配置文件的方式使用,例如自己写调用脚本,或者使用 mvn 插件的方式,其实实现起来还是很简单的.虽然简单,但还是不够 ...
- [springboot 开发单体web shop] 2. Mybatis Generator 生成common mapper
Mybatis Generator tool 在我们开启一个新项目的研发后,通常要编写很多的entity/pojo/dto/mapper/dao..., 大多研发兄弟们都会抱怨,为什么我要重复写CRU ...
- Idea创建Maven Web项目的web.xml版本问题
问题描述:创建Maven Web项目时,选择MavenWebapp模板时,自动生成的web.xml文件版本为1.4,如图所示 如何才能修改为常用的4.0版本的xml文件呢? 这个文件是从Maven仓库 ...
- 解决maven生成的web项目下的servlet.jar与tomcat自带servlet.jar冲突的问题
使用maven生成web工程后,编译需要下servlet-api.jar和jsp-api.jar文件. pom文件中的写法为: <dependency> <groupId>ja ...
- Maven Web项目配置Mybatis
一.添加Mybatis和数据库相关的包 1 pom.xml中添加的包有mybatis,mybatis-spring,druid,MySQL-connector-Java,commons-io,refl ...
- maven web项目的web.xml报错The markup in the document following the root element must be well-formed.
maven项目里面的web.xml开头约束是这样的 <?xml version="1.0" encoding="UTF-8"?> <web-a ...
- idea中建立maven web项卡在Generating Project in Batch mode
Maven命令执行到Generating Project in Batch mode 卡住,原因是网络带宽不足问题!需要下载一个约5.1M的xml文件. Maven一般命令:mvn archetype ...
- spring web项目下,判断项目是否启动完成
本文同时发布于见鬼网:https://faceghost.com/article/483341 概述:spring 加载完成后,我们有时候会做一些初始化工作,如加载一些缓存,DB,等,这里采用实现Se ...
随机推荐
- codeforces 572 D. Minimization(dp+ 思维)
题目链接:http://codeforces.com/contest/572/problem/D 题意:给出一个序列,可以任意调整序列的顺序,使得给出的式子的值最小 题解:显然要先排一下序,然后取相邻 ...
- webpack,vue中定义的别名怎么在模板, css sass less的图片地址上使用
webpack 的别名好处大家也都了解, 但是 vue 的模板中, 对图片地址使用别名时总出现问题, 很久时间的时间都没找到解决办法, 一度认为是 webpack 的原因... alias: { 's ...
- Erlang模块gen_tcp翻译
概述 TCP/IP套接字接口 描述 gen_tcp模块提供了使用TCP / IP协议与套接字进行通信的功能. 以下代码片段提供了一个客户端连接到端口5678的服务器的简单示例,传输一个二进制文件并关闭 ...
- Java并发编程(一):进程和线程之由来
转自:http://www.cnblogs.com/dolphin0520/p/3910667.html 在前面,已经介绍了Java的基础知识,现在我们来讨论一点稍微难一点的问题:Java并发编程.当 ...
- 当递归遇到synchronized
面试题:有一个synchronized方法,加入该方法发生递归调用,会导致线程死锁码? 解析: 所谓递归函数就是自调用函数,在函数体内直接或间接的调用自己,即函数的嵌套是函数本身. 递归方式有两种:直 ...
- 纯css制作电闪雷鸣的天气图标
效果 效果图如下 实现思路 使用box-shadow属性写几个圆,将这些圆错落的组合在一起,形成云朵图案 after伪元素写下面的投影样式 before伪元素写黄色闪电的样式 dom结构 用两个嵌 ...
- 固定定位下的div水平居中
发现了一个之前未留意的知识点,做个笔记. 当一个块级元素的父元素开启了flex布局后,我们可以很轻松的将这个元素居中对齐,可以在父元素上加 justify-content: center; align ...
- ORACLE SQL语句练习题
--1:选择部门30中的所有员工select * from emp where deptno=30--2:列出所有办事员(clerk) 的姓名.编号和部门编号select empno,ename,de ...
- JavaScript和JQuery进行页面跳转
1.JavaScript页面跳转 .我们可以利用http的重定向来跳转 window.location.replace("网址"); .使用href来跳转 window.locat ...
- Linux之文件权限、用户管理
世界真美好!