Giter Site home page Giter Site logo

Comments (2)

genghe123 avatar genghe123 commented on August 19, 2024

pom.xml

     <plugin>
            <groupId>org.mybatis.generator</groupId>
            <artifactId>mybatis-generator-maven-plugin</artifactId>
            <version>1.3.2</version>

            <configuration>
                <verbose>true</verbose>
                <overwrite>true</overwrite>
                <configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
            </configuration>

            <dependencies>
                <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <version>5.1.9</version>
                </dependency>
            </dependencies>
        </plugin>

generatorConfig.xml

<context id="context1" targetRuntime="MyBatis3">
    <!-- 抑制警告 -->
    <property name="suppressTypeWarnings" value="true"/>
    
    <!-- generate entity时,生成hashcode和equals方法 -->
    <!-- <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin" /> -->
    <!-- generate entity时,生成serialVersionUID -->
    <plugin type="org.mybatis.generator.plugins.SerializablePlugin"/>
    <!-- 这个插件只会增加字符串字段映射到一个JDBC字符的方法 -->
    <plugin type="org.mybatis.generator.plugins.CaseInsensitiveLikePlugin"/>
    <!-- genenat entity时,生成toString -->
    <plugin type="org.mybatis.generator.plugins.ToStringPlugin"/>

    <!-- 是否去除自动生成的注释 true:是 : false:否 -->
    <commentGenerator>
        <property name="suppressAllComments" value="true"/>
        <property name="suppressDate" value="true"/>
    </commentGenerator>

    <!-- 数据库配置文件的url是不能直接拷贝过来用的,需要把&换成'&amp;' -->
    <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                    connectionURL="jdbc:mysql://localhost:3306/test?useUnicode=true&amp;charaterEncoding=utf-8&amp;allowMultiQueries=true"
                    userId="testuser" password="123456">
    </jdbcConnection>

    <javaTypeResolver>
        <property name="forceBigDecimals" value="false"/>
    </javaTypeResolver>

    <!-- generate Model -->
    <javaModelGenerator targetPackage="main.generated.model"
                        targetProject="${project.build.directory}/../src/main/java/main/generated/mapper">
        <property name="enableSubPackages" value="true"/>
        <property name="trimStrings" value="true"/>
        <property name="isMergeable" value="false"/>
    </javaModelGenerator>

    <!-- generate xml -->
    <sqlMapGenerator targetPackage="main.generated.mapper"
                     targetProject="${project.build.directory}/../src/main/java/main/generated/mapper">
        <property name="enableSubPackages" value="true"/>
    </sqlMapGenerator>

    <!-- generate Mapper -->
    <javaClientGenerator type="XMLMAPPER" targetPackage="main.generated.mapper"
                         targetProject="${project.build.directory}/../src/main/java/main/generated/mapper">
        <property name="enableSubPackages" value="true"/>
    </javaClientGenerator>

    <!--
      catalog CDATA #IMPLIED
      schema CDATA #IMPLIED
      tableName CDATA #REQUIRED
      alias CDATA #IMPLIED
      domainObjectName CDATA #IMPLIED
      enableInsert CDATA #IMPLIED
      enableSelectByPrimaryKey CDATA #IMPLIED
      enableUpdateByPrimaryKey CDATA #IMPLIED
      enableDeleteByPrimaryKey CDATA #IMPLIED
      enableCountByExample CDATA #IMPLIED
      enableUpdateByExample CDATA #IMPLIED
      enableDeleteByExample CDATA #IMPLIED
      enableSelectByExample CDATA #IMPLIED
      selectByExampleQueryId CDATA #IMPLIED
      selectByPrimaryKeyQueryId CDATA #IMPLIED
      modelType CDATA #IMPLIED
      escapeWildcards CDATA #IMPLIED
      delimitIdentifiers CDATA #IMPLIED
      delimitAllColumns CDATA #IMPLIED
     -->

    <table schema="test" tableName="college" modelType="flat"
           enableCountByExample="true" enableUpdateByExample="true"
           enableDeleteByExample="true" enableSelectByExample="true"
           selectByExampleQueryId="true"/>

    <table schema="test" tableName="course" modelType="flat"
           enableCountByExample="true" enableUpdateByExample="true"
           enableDeleteByExample="true" enableSelectByExample="true"
           selectByExampleQueryId="true"/>

    <table schema="test" tableName="role" modelType="flat"
           enableCountByExample="true" enableUpdateByExample="true"
           enableDeleteByExample="true" enableSelectByExample="true"
           selectByExampleQueryId="true"/>

    <table schema="test" tableName="selectedcourse" modelType="flat"
           enableCountByExample="true" enableUpdateByExample="true"
           enableDeleteByExample="true" enableSelectByExample="true"
           selectByExampleQueryId="true"/>

    <table schema="test" tableName="student" modelType="flat"
           enableCountByExample="true" enableUpdateByExample="true"
           enableDeleteByExample="true" enableSelectByExample="true"
           selectByExampleQueryId="true"/>

    <table schema="test" tableName="teacher" modelType="flat"
           enableCountByExample="true" enableUpdateByExample="true"
           enableDeleteByExample="true" enableSelectByExample="true"
           selectByExampleQueryId="true"/>

    <table schema="test" tableName="userlogin" modelType="flat"
           enableCountByExample="true" enableUpdateByExample="true"
           enableDeleteByExample="true" enableSelectByExample="true"
           selectByExampleQueryId="true"/>
</context>

</generatorConfiguration>

from examination_system.

zhangyuhong516 avatar zhangyuhong516 commented on August 19, 2024

谢谢你

from examination_system.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.