springboot 1.5 sqlserver逆向生成

把注释打开先,在build标签下的plugins标签下


        <!--<plugin>-->
            <!--<groupId>org.mybatis.generator</groupId>-->
            <!--<artifactId>mybatis-generator-maven-plugin</artifactId>-->
            <!--<version>1.3.2</version>-->
            <!--<executions>-->
                <!--<execution>-->
                    <!--<id>Generate MyBatis Artifacts</id>-->
                    <!--<phase>package</phase>-->
                    <!--<goals>-->
                        <!--<goal>generate</goal>-->
                    <!--</goals>-->
                <!--</execution>-->
            <!--</executions>-->
            <!--<configuration>-->
                <!--&lt;!&ndash;允许移动生成的文件 &ndash;&gt;-->
                <!--<verbose>true</verbose>-->
                <!--&lt;!&ndash; 是否覆盖 &ndash;&gt;-->
                <!--<overwrite>false</overwrite>-->
                <!--&lt;!&ndash; 自动生成的配置 &ndash;&gt;-->
                <!--<configurationFile>-->
                    <!--src/main/resources/mybatis-generator.xml</configurationFile>-->
            <!--</configuration>-->
        <!--</plugin>-->
<?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>
   <!-- 这里改成自己的maven地址就行 -->
 <classPathEntry
            location="E:\apache-maven-3.5.3\mavenJar\com\microsoft\sqlserver\sqljdbc4\4.0\sqljdbc4-4.0.jar" />
    <context id="testTables" targetRuntime="MyBatis3Simple">
        <!-- 忽略警告信息 -->
        <property name="suppressTypeWarnings" value="true" />
        <!-- 使用插件:生成po类时,让类实现序列化接口 -->
        <plugin type="org.mybatis.generator.plugins.SerializablePlugin" />
        <!-- 使用插件:生成po类时,给类添加toString函数 -->
        <plugin type="org.mybatis.generator.plugins.ToStringPlugin" />
        <!-- 使用插件:生成mybatis配置文件 -->
        <plugin type="org.mybatis.generator.plugins.MapperConfigPlugin">
            <!-- 配置文件名 -->
            <property name="fileName" value="mybatis-config.xml"/>
            <!-- 配置文件所在包名 -->
            <!-- <property name="targetPackage" value="cn.fangfa.config" /> -->
            <!-- 配置文件所在目录 -->
            <property name="targetProject" value="src/main/java" />
        </plugin>
        <commentGenerator>
            <!-- 是否去除自动生成的注释 true:是 : false:否 -->
            <property name="suppressAllComments" value="true" />
        </commentGenerator>

        <!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
        <jdbcConnection driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver"
                        connectionURL="jdbc:sqlserver://localhost:1433;DatabaseName=test"
                        userId="sa"
                        password="123456">
        </jdbcConnection>

        <!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL
            和 NUMERIC 类型解析为java.math.BigDecimal -->
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false" />
        </javaTypeResolver>
        <!-- targetProject:生成PO类的位置 -->
        <javaModelGenerator targetPackage="com.fangfa.jiliang.bean"
                            targetProject="src/main/java">
            <!-- enableSubPackages:是否让schema作为包的后缀 -->
            <property name="enableSubPackages" value="false" />
            <!-- 从数据库返回的值被清理前后的空格 -->
            <property name="trimStrings" value="true" />
        </javaModelGenerator>

        <!-- targetProject:mapper接口生成的位置 -->
        <sqlMapGenerator targetPackage="mapper"
                         targetProject="src/main/resources">
            <!-- enableSubPackages:是否让schema作为包的后缀 -->
            <property name="enableSubPackages" value="false" />
        </sqlMapGenerator>


        <!-- targetPackage:mapper接口映射文件生成的位置 -->
        <javaClientGenerator type="XMLMAPPER"
                             targetPackage="com.fangfa.jiliang.dao" targetProject="src/main/java">
            <!-- enableSubPackages:是否让schema作为包的后缀 -->
            <property name="enableSubPackages" value="false" />
        </javaClientGenerator>


        <!-- 指定数据库表 -->
        <!-- schema即为数据库名(可以不写), tableName为对应的数据库表, domainObjectName是要生成的实体类 -->
        <table tableName="user" domainObjectName="User"></table>
        <!-- <table tableName="state" domainObjectName="State"></table>
          <table tableName="customer" domainObjectName="Customer"></table>
        <table tableName="orgunization" domainObjectName="Orgunization"></table>
        <table tableName="progress" domainObjectName="Progress"></table>
        <table tableName="record" domainObjectName="Record">
            <columnOverride column="orgunizeId" javaType="Orgunization"
                property="orgunization" />
            <columnOverride column="progrssId" javaType="Progress"
                property="progress" />
        </table>
 -->
        <!-- 有些表的字段需要指定java类型 <table schema="" tableName="" domainObjectName="Product">
            <columnOverride column="" javaType="" /> </table> -->

    </context>
</generatorConfiguration>


干就完事了

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值