Maven之Mybatis逆向生成

1.配置pom(引入插件)
Maven之Mybatis逆向生成_第1张图片

 <plugin>
	   <groupId>org.mybatis.generatorgroupId>
	   <artifactId>mybatis-generator-maven-pluginartifactId>
	   <version>1.3.5version>
	   <configuration>
	       <verbose>trueverbose>
	       <overwrite>trueoverwrite>
	       <configurationFile>src/main/resources/mybatis/generatorConfig.xmlconfigurationFile>
	   configuration>
plugin>

2.编写mybatis生成配置
Maven之Mybatis逆向生成_第2张图片

  • generatorConfig.xml



<generatorConfiguration>
    
    <properties resource="mybatis/generator.properties">properties>

    
    <classPathEntry location="${jdbc.driverLocation}"/>

    <context id="default" targetRuntime="MyBatis3">
        
        <plugin type="org.mybatis.generator.plugins.ToStringPlugin"/>


        
        <commentGenerator>
            <property name="suppressDate" value="true"/>
            <property name="suppressAllComments" value="true"/>
        commentGenerator>

        
        <jdbcConnection
                driverClass="${jdbc.driverClass}"
                connectionURL="${jdbc.connectionURL}"
                userId="${jdbc.userId}"
                password="${jdbc.password}">
        jdbcConnection>


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


        
        <javaModelGenerator targetPackage="${model.targetPackage}"
                            targetProject="${model.targetProject}">

            
            <property name="enableSubPackages" value="false"/>
            
            <property name="constructorBased" value="true"/>
            
            <property name="trimStrings" value="true"/>
            
            <property name="immutable" value="false"/>
        javaModelGenerator>

        
        <sqlMapGenerator targetPackage="${sql.targetPackage}"
                         targetProject="${sql.targetProject}">
            <property name="enableSubPackages" value="true"/>
        sqlMapGenerator>

        
        <javaClientGenerator targetPackage="${client.targetPackage}"
                             targetProject="${client.targetProject}"
                             type="XMLMAPPER">
            <property name="enableSubPackages" value="true"/>
        javaClientGenerator>
        
    context>
generatorConfiguration>

  • generator.properties
jdbc.driverLocation=G:\\JAVA\\SoftwareAndPlugins\\apache-maven-3.6.0\\maven-repo\\mysql\\mysql-connector-java\\5.1.47\\mysql-connector-java-5.1.47.jar
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.connectionURL=jdbc:mysql://localhost:3306/toefl?useSSL=false&useUnicode=true&characterEncoding=utf8
jdbc.userId=root
jdbc.password=123456
model.targetProject =./src/main/java
model.targetPackage =com.team.rrtf.pojo
sql.targetProject =src/main/resources/mybatis
sql.targetPackage =mapper
client.targetProject =src/main/java
client.targetPackage =com.team.rrtf.dao

3.生成
Maven之Mybatis逆向生成_第3张图片

你可能感兴趣的:(使用方面,#,Mybatis)