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>--> <!--<!–允许移动生成的文件 –>--> <!--<verbose>true</verbose>--> <!--<!– 是否覆盖 –>--> <!--<overwrite>false</overwrite>--> <!--<!– 自动生成的配置 –>--> <!--<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>
干就完事了