Intellij IDEA springboot maven 配置mybatis-generator,自动从数据库中生成代码
来源:互联网 发布:淘宝零食高颜值知乎 编辑:程序博客网 时间:2024/06/04 18:19
1.生成generatorConfig.xml文件,路径如下
配置内容
<?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/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,可能是路径没写对,注意是\,且从根目录开始识别
阅读全文
0 0
- Intellij IDEA springboot maven 配置mybatis-generator,自动从数据库中生成代码
- IntelliJ IDEA Maven Mybatis generator 自动生成代码 MAC系统
- Intellij IDEA中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 中使用 MyBatis-generator 自动生成 MyBatis 代码
- Intellij IDEA 中使用 MyBatis-generator 自动生成 MyBatis 代码
- Intellij IDEA 中使用 MyBatis-generator 自动生成 MyBatis 代码
- Intellij IDEA中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA中使用Mybatis-generator自动生成Mtbatis代码
- idea中mybatis generator自动生成代码配置 数据库是sqlserver
- maven + MyBatis Generator 自动生成代码配置
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码
- Spring事物理解
- 深入分析网站手机短信验证码接收平台
- BZOJ2957 楼房重建(线段树)
- Tomcat设置maxThreads,acceptCount
- Struts2(2)
- Intellij IDEA springboot maven 配置mybatis-generator,自动从数据库中生成代码
- leetcode--Pow(x, n)
- 机器学习5:逻辑回归
- PHP 中如何使用 AJAX
- 【hdu 1069】Monkey and Banana(dp)
- U盘里格式化了怎么办?教你一招,快速找回格式化的文件!
- Java中的内部类
- C语言实现:折半查找(二分查找)
- 初学acmer--读《算法竞赛经典入门》笔记(六)p45-48