标签:报错 cer 技术 zone mybatis3 target mode string driver
命令:
mvn mybatis-generator:generate
项目结构:
generatorConfig.xml内容示例
<?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> <context id="mysqlgenerator" targetRuntime="MyBatis3"> <property name="autoDelimitKeywords" value="true"/> <!--可以使用``包括字段名,避免字段名与sql保留字冲突报错--> <property name="beginningDelimiter" value="`"/> <property name="endingDelimiter" value="`"/> <!-- 自动生成toString方法 --> <plugin type="org.mybatis.generator.plugins.ToStringPlugin"/> <!-- 自动生成equals方法和hashcode方法 --> <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin"/> <!-- 非官方插件 https://github.com/itfsw/mybatis-generator-plugin --> <!-- 查询单条数据插件 --> <plugin type="com.itfsw.mybatis.generator.plugins.SelectOneByExamplePlugin"/> <!-- 查询结果选择性返回插件 --> <plugin type="com.itfsw.mybatis.generator.plugins.SelectSelectivePlugin"/> <!-- Example Criteria 增强插件 --> <plugin type="com.itfsw.mybatis.generator.plugins.ExampleEnhancedPlugin"/> <!-- 数据Model属性对应Column获取插件 --> <plugin type="com.itfsw.mybatis.generator.plugins.ModelColumnPlugin"/> <!-- 逻辑删除插件 --> <plugin type="com.itfsw.mybatis.generator.plugins.LogicalDeletePlugin"> <!-- 这里配置的是全局逻辑删除列和逻辑删除值,当然在table中配置的值会覆盖该全局配置 --> <!-- 逻辑删除列类型只能为数字、字符串或者布尔类型,数据库中用tinyint(1) --> <property name="logicalDeleteColumn" value="deleted"/> <!-- 逻辑删除-已删除值 --> <property name="logicalDeleteValue" value="1"/> <!-- 逻辑删除-未删除值 --> <property name="logicalUnDeleteValue" value="0"/> </plugin> <commentGenerator> <property name="suppressDate" value="true"/> <!--<property name="suppressAllComments" value="true"/>--> </commentGenerator> <!--数据库连接信息--> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.1.100:3306/theorydance?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&verifyServerCertificate=false&useSSL=false" userId="root" password="123456"/> <javaTypeResolver> <property name="useJSR310Types" value="true"/> </javaTypeResolver> <javaModelGenerator targetPackage="demo.theorydance.db.domain" targetProject="src/main/java"/> <sqlMapGenerator targetPackage="demo.theorydance.db.dao" targetProject="src/main/resources"/> <javaClientGenerator type="XMLMAPPER" targetPackage="demo.theorydance.db.dao" targetProject="src/main/java"/> <!--表名--> <table tableName="student"></table> </context> </generatorConfiguration>
pom.xml中添加插件
<build> <plugins> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.7</version> <configuration> <configurationFile> mybatis-generator/generatorConfig.xml </configurationFile> <overwrite>true</overwrite> <verbose>true</verbose> </configuration> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.46</version> </dependency> <dependency> <groupId>com.itfsw</groupId> <artifactId>mybatis-generator-plugin</artifactId> <version>1.2.12</version> </dependency> </dependencies> </plugin> </plugins> </build>
标签:报错 cer 技术 zone mybatis3 target mode string driver
原文地址:https://www.cnblogs.com/TheoryDance/p/12536374.html