and generating a reverse mybatis dao mapper file example.java

mabatis plug

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

generatorConfig.xml, resource directories and lower positions, (the same directory and mybatis)

<?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>
    <!--数据库驱动jar 需要配置成自己实际的路径-->
    <classPathEntry location="C:\Users\.m2\repository\org\postgresql\postgresql\42.2.5\postgresql-42.2.5.jar" />

    <context id="DB2Tables" targetRuntime="MyBatis3">
        <!- commentGenerator<->removing the annotation  
        >
            <property name="suppressAllComments" value="true" />
        </commentGenerator>

    <!--数据库连接 -->
    <jdbcConnection driverClass="org.postgresql.Driver"
                    connectionURL="jdbc:postgresql://192.168.1.22:5432/test"
                    userId="username"
                    password="password">
    </jdbcConnection>
        <!--默认false
           Java type resolver will always use java.math.BigDecimal if the database column is of type DECIMAL or NUMERIC.
         -->
        < JavaTypeResolver > 
            < Property name = "forceBigDecimals" value = "to false"  /> 
        </ javaTypeResolver > 

        <-! Generating entity class and package names specified address generation (which may be custom address, but the path does not exist will not automatically be created Maven generated in the target directory, created automatically) -> 
        < javaModelGenerator targetPackage = "com.test.model" targetProject = "MAVEN" > 
            < Property name = "enableSubPackages" value = "to false"  /> 
            < Property name = " trimStrings " value ="true" />
        </javaModelGenerator> 
        <! - generated SQLMAP file is automatically created target directory -> 
        < sqlMapGenerator targetPackage = "com.test.mybatis"   targetProject = "MAVEN" > 
            < Property name = "enableSubPackages" value = "false"  /> 
        </ sqlMapGenerator > 
        <! - generated Dao file can be configured type = "XMLMAPPER" generate dao xml implementation context id = "DB2Tables" modify targetRuntime = "MyBatis3" target directory is automatically created -> 
        < javaClientGenerator of the type = "XMLMAPPER" targetPackage = "COM. test.dao "  targetProject="MAVEN">
            <property name= "enableSubPackages" value = "to false"  /> 
        </ javaClientGenerator > 
<---->! 
        <-! correspondence mysql database table may be added by the primary key fields from a field name is ignored and the like to generate a corresponding one of a table dao model mybatisSQLMAPPER -> 
       < Table tableName = "model_system" domainObjectName = "System Model"  /> 
    </ context > 
</ generatorConfiguration >

If the reported red, very likely not "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" dtd file

Method 1: Download dtd file configuration

 

 Second way: I never tried

https://zhidao.baidu.com/question/1964757312532141780.html

Generate dao mapper example.java file

For example with IDEA

 

Guess you like

Origin www.cnblogs.com/zhzhlong/p/11700066.html