mybatis-plus代码生成器xml模板
时间: 2023-07-21 22:34:03 浏览: 104
以下是 MyBatis-Plus 代码生成器的 XML 模板:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<mybatisPlusGenerator>
<!-- 全局配置 -->
<globalConfig>
<fileOverride>true</fileOverride>
<outputDir>src/main/java</outputDir>
<author>作者名</author>
<open>false</open>
<baseResultMap>true</baseResultMap>
<baseColumnList>true</baseColumnList>
<serviceName="%sService"/>
<controllerMappingHyphenStyle>true</controllerMappingHyphenStyle>
</globalConfig>
<!-- 数据源配置 -->
<dataSource>
<driverName>com.mysql.jdbc.Driver</driverName>
<url>jdbc:mysql://localhost:3306/db_name</url>
<username>root</username>
<password>password</password>
</dataSource>
<!-- 策略配置 -->
<strategy>
<tablePrefix>tbl_</tablePrefix>
<fieldPrefix>id_</fieldPrefix>
<naming>NamingStrategy.underline_to_camel</naming>
<superEntityClass>com.example.demo.entity.BaseEntity</superEntityClass>
<superEntityColumns>created_at,updated_at</superEntityColumns>
<superMapperClass>com.baomidou.mybatisplus.core.mapper.BaseMapper</superMapperClass>
<superServiceClass>com.baomidou.mybatisplus.extension.service.IService</superServiceClass>
<superServiceImplClass>com.baomidou.mybatisplus.extension.service.impl.ServiceImpl</superServiceImplClass>
<superControllerClass>com.baomidou.mybatisplus.extension.api.ApiController</superControllerClass>
<entityLombokModel>false</entityLombokModel>
<entityTableFieldAnnotationEnable>true</entityTableFieldAnnotationEnable>
<entitySerialVersionUID>true</entitySerialVersionUID>
<entityColumnConstant>true</entityColumnConstant>
<controllerMappingHyphenStyle>false</controllerMappingHyphenStyle>
</strategy>
<!-- 包配置 -->
<packageConfig>
<parent>com.example.demo</parent>
<moduleName>demo</moduleName>
<entity>entity</entity>
<mapper>mapper</mapper>
<xml>mapper.xml</xml>
<service>service</service>
<serviceImpl>service.impl</serviceImpl>
<controller>controller</controller>
</packageConfig>
<!-- 模板配置 -->
<templateConfig>
<controller>/templates/controller.java.vm</controller>
<service>/templates/service.java.vm</service>
<serviceImpl>/templates/serviceImpl.java.vm</serviceImpl>
<mapper>/templates/mapper.java.vm</mapper>
<entity>/templates/entity.java.vm</entity>
</templateConfig>
</mybatisPlusGenerator>
```
其中,`globalConfig` 是全局配置,包括文件输出路径、作者名、是否打开输出目录等;`dataSource` 是数据源配置,包括数据库连接信息;`strategy` 是策略配置,包括表前缀、字段前缀、命名策略等;`packageConfig` 是包配置,包括包名、模块名、实体类包名、Mapper 接口包名等;`templateConfig` 是模板配置,包括生成代码所使用的模板文件路径。
阅读全文