mybatis generator自动生成代码 相对路径式配置
来源:互联网 发布:阿里云服务器做git 编辑:程序博客网 时间:2024/06/05 11:43
有很多博客已经有mybatis的自动生成配置了, 但是好多都是配置的绝对路径, 然后就自己整理了下配置相对路径的方式
1 这是pom.xml中mybatis-generator-maven-plugin插件的配置
<plugin> <!-- 用maven mybatis插件 如果不在plugin里面添加依赖包得引用的话,会找不到相关得jar包, 在plugin外部得jar包,他不会去找到并执行, 所以要把plugin运行依赖得jar配置都放在里面 --> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.2</version> <executions> <execution> <id>Generate MyBatis Artifacts</id> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> <verbose>true</verbose> <overwrite>true</overwrite> <jdbcDriver>com.mysql.jdbc.Driver</jdbcDriver> <jdbcURL>jdbc:mysql://ip:3306/test</jdbcURL> <jdbcUserId>root</jdbcUserId> <jdbcPassword>****</jdbcPassword> </configuration> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <!-- 引用依赖库的版本 --> <version>5.1.35</version> </dependency> <dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.3.2</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <!-- 引用依赖库的版本 --> <version>${mybatis.version}</version> </dependency> </dependencies> </plugin>
2 这是generatorConfig.xml:
<!-- 一个数据库一个context --> <context id="infoGuardian"> <!-- 注释 --> <commentGenerator > <property name="suppressAllComments" value="false"/><!-- 是否取消注释 --> <property name="suppressDate" value="true" /> <!-- 是否生成注释代时间戳--> </commentGenerator> <!-- jdbc连接 --> <jdbcConnection driverClass="${driver}" connectionURL="${url}" userId="${user}" password="${password}" /> <!-- 类型转换 --> <javaTypeResolver> <!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) --> <property name="forceBigDecimals" value="false"/> </javaTypeResolver> <!-- 生成实体类地址 --> <javaModelGenerator targetPackage="com.bj.entity" targetProject="src/main/java" > <!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] --> <property name="enableSubPackages" value="false"/> <!-- 是否针对string类型的字段在set的时候进行trim调用 --> <property name="trimStrings" value="true"/> </javaModelGenerator> <!-- 生成mapxml文件 --> <sqlMapGenerator targetPackage="com.bj.mapping" targetProject="src/main/java" > <!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] --> <property name="enableSubPackages" value="false" /> </sqlMapGenerator> <!-- 生成mapxml对应client,也就是接口dao --> <javaClientGenerator targetPackage="com.bj.mapping
" targetProject="src/main/java
" type="XMLMAPPER" > <!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] --> <property name="enableSubPackages" value="false" /> </javaClientGenerator> <!-- 配置表信息 --> <table tableName="students" domainObjectName="Student" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"> <!-- tableName为对应的数据库表 domainObjectName是要生成的实体类名 enable*ByExample 是否生成 example类 --> <!-- 忽略列,不生成bean 字段 --> <ignoreColumn column="FRED" /> <!-- 指定列的java数据类型 --> <!-- <columnOverride column="LONG_VARCHAR_FIELD" jdbcType="VARCHAR" /> --> </table> </context> </generatorConfiguration>
以上配置基于maven项目, generatorConfig.xml放在resources目录下, 开发工具是idea, 可以利用maven里面的plugins点击对应的mybatis-generator:generate 自动生成代码并可以直接使用.
阅读全文
1 0
- mybatis generator自动生成代码 相对路径式配置
- maven + MyBatis Generator 自动生成代码配置
- Generator-Mybatis自动生成代码
- MyBatis Generator自动生成代码
- mybatis-generator自动生成代码
- mybatis自动生成代码generator
- MyBatis Generator 自动生成代码
- Mybatis-Generator自动生成代码
- MyBatis-generator 自动生成代码
- mybatis-generator自动生成代码
- mybatis自动生成代码generator.xml的配置
- mybatis-generator【mybatis代码自动生成】
- MBG(MyBatis Generator):MyBatis自动代码生成;
- mybatis mybatis-generator 代码自动生成工具
- 使用MyBatis-generator 自动生成MyBatis代码
- mybatis mybatis-generator 代码自动生成工具
- MyBatis使用Generator自动生成代码
- MyBatis使用Generator自动生成代码
- npm install 运行时报错
- SaaS 公司创始人最常犯的 10 个错误
- 设计模式入门
- QuartZ Cron表达式
- ie7兼容问题
- mybatis generator自动生成代码 相对路径式配置
- 第10周项目1 (1)层次遍历算法的验证
- 环境问题
- Swift【优化Swift项目编译时间】
- ros 定义自己的消息---Python
- vue项目使用axios发送请求让ajax请求头部携带cookie
- 如何选择最佳前端框架
- (三)项目模块划分以及资源管理
- Vue填坑之路