Intellij IDEA springboot maven 配置mybatis-generator,自动从数据库中生成代码
2017-08-08 10:52
405 查看
1.生成generatorConfig.xml文件,路径如下
配置内容
2.在pom.xml中添加jar包和插件
配置如下;
3.执行操作
出现The specified target project directory src\main\java does not exist,可能是路径没写对,注意是\,且从根目录开始识别
配置内容
<?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="C:\Users\xxx\.m2\repository\mysql\mysql-connector-java\5.1.38\mysql-connector-java-5.1.38.jar" /> <context id="context1" targetRuntime="MyBatis3"> <commentGenerator> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="true" /> <!--数据库连接的信息:驱动类、连接地址、用户名、密码 --> </commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/springboot?characterEncoding=UTF-8" userId="xxxx" password="xxxx" /> <javaModelGenerator targetPackage="com.example.demo.bean.po" targetProject="src\main\java" /> <sqlMapGenerator targetPackage="com.example.demo.mapper" targetProject="src\main\java" /> <javaClientGenerator targetPackage="com.example.demo.bean.dao" targetProject="src\main\java" type="XMLMAPPER" /> <!-- shema 数据库 tableName表明 --> <table schema="springboot" tableName="user" enableInsert="true" enableCountByExample="true" enableSelectByPrimaryKey="true" enableSelectByExample="true" enableUpdateByPrimaryKey="true" enableUpdateByExample="true" enableDeleteByPrimaryKey="true" enableDeleteByExample="true"> </table> </context> </generatorConfiguration>
2.在pom.xml中添加jar包和插件
配置如下;
<dependencies><dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-maven-plugin -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
</dependency>
<!-- 添加 JSTL 支持 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
<build> <plugins> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.5</version> <configuration> <!--配置文件的位置--> <configurationFile>src/main/resources 8e3c /generatorConfig.xml</configurationFile> <verbose>true</verbose> <overwrite>true</overwrite> </configuration> <executions> <execution> <id>Generate MyBatis Artifacts</id> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
3.执行操作
出现The specified target project directory src\main\java does not exist,可能是路径没写对,注意是\,且从根目录开始识别
相关文章推荐
- idea中mybatis generator自动生成代码配置 数据库是sqlserver
- SpringBoot学习-如何使用mybatis-generator-maven-plugin自动生成代码
- IntelliJ IDEA Maven Mybatis generator 自动生成代码 MAC系统
- IDEA Maven Mybatis generator 自动生成代码(实例讲解)
- SpringBoot系列: 使用MyBatis maven插件自动生成java代码
- idea 搭建 springMVC+mybatis+maven 项目(三)mybatis-generater自动生成MyBatis代码
- mybatis-generator-maven-plugin插件自动生成代码的配置方法
- Mybatis 自动生成代码配置 -Spring + Maven 环境
- maven + MyBatis Generator 自动生成代码配置
- springboot-mybatis-generator 自动生成代码
- MyBatis Generator作为maven插件自动生成增删改查代码及配置文件例子
- idea中mybatis-generator插件实现数据库表自动生成相关接口、pojo、和xml配置
- spring boot配置mybatis代码自动生成(mybatis通用mapper相关基础代码自动生成)
- Intellij IDEA中使用MyBatis-generator 自动生成MyBatis代码
- idea中使用Mybatis-generator自动生成数据库持久层代码
- 基于SpringBoot+Springmvc+mybatis+mybatis-generator代码自动生成的框架。
- SpringBoot学习教程 - 06 - 集成MyBatis Generator自动生成代码
- mybatis-generator 代码自动生成工具(maven方式)
- maven+mybatis+mybatis-generator+sql server 2005自动生成代码,加上自定义分页插件和批量插入更新插件