idea maven mybatis generator插件逆向工程

创建一个maven项目
idea maven mybatis generator插件逆向工程_第1张图片
idea maven mybatis generator插件逆向工程_第2张图片
idea maven mybatis generator插件逆向工程_第3张图片
完成之后目录结构如下:
idea maven mybatis generator插件逆向工程_第4张图片

pom文件



<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0modelVersion>

  <groupId>com.charlesgroupId>
  <artifactId>mygeneratorartifactId>
  <version>1.0-SNAPSHOTversion>
  <packaging>warpackaging>

  <name>generator Maven Webappname>
  
  <url>http://www.example.comurl>

  <properties>
    <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
    <maven.compiler.source>1.7maven.compiler.source>
    <maven.compiler.target>1.7maven.compiler.target>
  properties>

  <dependencies>
    <dependency>
      <groupId>mysqlgroupId>
      <artifactId>mysql-connector-javaartifactId>
      <version>5.1.30version>
    dependency>
    <dependency>
      <groupId>org.mybatis.generatorgroupId>
      <artifactId>mybatis-generator-coreartifactId>
      <version>1.3.2version>
    dependency>
    <dependency>
      <groupId>junitgroupId>
      <artifactId>junitartifactId>
      <version>4.11version>
      <scope>testscope>
    dependency>
  dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.mybatis.generatorgroupId>
        <artifactId>mybatis-generator-maven-pluginartifactId>
        <version>1.3.2version>
        <configuration>
          
          <configurationFile>src/main/resources/generatorConfig.xmlconfigurationFile>
          <verbose>trueverbose>
          <overwrite>trueoverwrite>
        configuration>
        <dependencies>
          <dependency>
            <groupId>org.mybatis.generatorgroupId>
            <artifactId>mybatis-generator-coreartifactId>
            <version>1.3.2version>
          dependency>
        dependencies>
      plugin>
    plugins>
  build>


project>

在resource下新建xml配置文件
idea maven mybatis generator插件逆向工程_第5张图片




<generatorConfiguration >
    
    
    <classPathEntry location="D:\\software\\dev\\maven\repository\\mysql\\mysql-connector-java\\5.1.30\\mysql-connector-java-5.1.30.jar"/>

    <context id="CharlesBatis" targetRuntime="MyBatis3" >
        <commentGenerator  >
            <property name="javaFileEncoding" value="UTF-8"/>
            <property name="suppressAllComments" value="false" />
            <property name="suppressDate" value="true"/>
        commentGenerator>

        
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                        connectionURL="jdbc:mysql://localhost:3306/taotao?useUnicode=true&characterEncoding=UTF-8" userId="root" password="123456" />

        
        <javaModelGenerator targetPackage="com.taotao.pojo"
                            targetProject=".\src">
            
            <property name="enableSubPackages" value="false" />
            
            <property name="trimStrings" value="true" />
        javaModelGenerator>
        
        <sqlMapGenerator targetPackage="com.taotao.mapper"
                         targetProject=".\src">
            
            <property name="enableSubPackages" value="false" />
        sqlMapGenerator>
        
        <javaClientGenerator type="XMLMAPPER"
                             targetPackage="com.taotao.mapper"
                             targetProject=".\src">
            
            <property name="enableSubPackages" value="false" />
        javaClientGenerator>

        
        <table schema="" tableName="tb_content">table>
        <table schema="" tableName="tb_content_category">table>
        <table schema="" tableName="tb_item">table>
        <table schema="" tableName="tb_item_cat">table>
        <table schema="" tableName="tb_item_desc">table>
        <table schema="" tableName="tb_item_param">table>
        <table schema="" tableName="tb_item_param_item">table>
        <table schema="" tableName="tb_order">table>
        <table schema="" tableName="tb_order_item">table>
        <table schema="" tableName="tb_order_shipping">table>
        <table schema="" tableName="tb_user">table>
    context>
generatorConfiguration>

注意:要修改为自己的驱动在这里插入图片描述
数据库名用户名密码修改成自己的
在这里插入图片描述

刷新一下maven右边会出现
idea maven mybatis generator插件逆向工程_第6张图片
配置下运行环境,应用,ok即可
idea maven mybatis generator插件逆向工程_第7张图片
点击运行后出现Process finished with exit code 0;说明成功了;
idea maven mybatis generator插件逆向工程_第8张图片
出现这个即可啦!

你可能感兴趣的:(java进阶)