spring-boot 代码生成工具
来源:互联网 发布:旧版淘宝下载安装 编辑:程序博客网 时间:2024/06/10 17:52
Mybatis Auto Code Generation Mapper/Service/Domain/SQL.xml, 主要是针对某个数据库所有表[参考配置文件ConfigConstants], 统一生成Domain/Service/Mapper,以及SQL.xml文件, 如:针对t_customer, 通过该应用生成CustonerInfo.java, CustomerSerivce.java/CustomerServiceImpl.java, CustomerMapper.java 以及 Customer-mapper.xml文件. 小工具类
1.Project run MainTest
2.Generate Code Config
3.Add dependencies to pom
4.spring-boot config
5.项目完整代码示例
https://github.com/leelance/code-generation
1.Project run MainTest
@RunWith(SpringRunner.class)@SpringBootTest(classes=SimpleApplication.class)public class MainTest { Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private TableService tableService; @Test public void main() { long startTime = System.currentTimeMillis(); logger.info("...........start application........."); tableService.run(); logger.info("...end application...Time: {}",(System.currentTimeMillis()-startTime)); }}
2.Generate Code Config
public interface ConfigConstants { /**定义Schema*/ String SCHEMA = "longchou-loan"; /**移除表前缀*/ String REMOVE_TABLE_PREFIX = "t_"; /**Domain后缀, CustomerInfo*/ String DOMAIN_SUFFIX = ""; /**生成文件路径*/ String FILE_PATH = "E:\\gitwork\\code-generation\\src\\main\\java"; /**MyBatis SQL生成文件路径*/ String SQL_PATH = "E:\\gitwork\\code-generation\\src\\main\\resources\\mappers"; /**生成Mapper.xml后缀名字, EX: customer-mapper.xml*/ String SQL_MAPPER_SUFFIX = "-mapper"; /**生成包名称*/ String ROOT_PACKAGE = "com.lance.code"; /**JavaBean包名称*/ String DOMAIN_PACKAGE = "domain"; /**service包名称*/ String SERVICE_PACKAGE = "service"; /**serviceImpl包名称*/ String SERVICE_impl_PACKAGE = "serviceImpl"; /**mapper包名称*/ String MAPPER_PACKAGE = "mapper";}
3.Add dependencies to pom
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.0.RELEASE</version></parent><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId></dependency><!-- Mybatis --><dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.1.1</version></dependency><!-- MYSQL --><dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId></dependency><dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.12</version></dependency><dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.4</version></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope></dependency><dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope></dependency>
4.spring-boot config
# IDENTITY (ContextIdApplicationContextInitializer)spring.application.index=Code.v1.1spring.application.name=Code Boot#MYBATISmybatis.type-aliases-package=com.lance.code.generation.domainmybatis.mapper-locations=classpath*:/mapper/*Mapper.xmlmybatis.configuration.map-underscore-to-camel-case=truemybatis.configuration.use-generated-keys=truemybatis.configuration.default-fetch-size=100mybatis.configuration.default-statement-timeout=30spring.datasource.url=jdbc:mysql://localhost:3306/loanspring.datasource.username=rootspring.datasource.password=123456spring.datasource.driver-class-name=com.mysql.jdbc.Driver
5.项目完整代码示例
https://github.com/leelance/code-generation
0 0
- spring-boot 代码生成工具
- spring boot中使用generator插件自动生成代码
- spring boot中使用generator插件自动生成代码
- spring boot配置mybatis代码自动生成(mybatis通用mapper相关基础代码自动生成)
- 一个struts+spring+hibernate的代码生成工具
- Spring MVC 典型分层Java代码生成工具
- Spring Boot 生成 war 包
- Spring-boot 生成验证码
- Spring-boot生成验证码
- Spring Boot CLI 工具安装
- spring boot 入门示例代码
- spring boot 代码切换错误
- 代码生成工具下载
- 关于代码生成工具
- 代码生成工具
- php 代码生成工具
- 代码自动生成工具
- 代码生成工具
- hdu1281棋盘游戏
- spring-boot集成shiro
- Git的下载安装及使用
- spring-boot集成Freemarker开发
- 云计算把Cisco, Dell和HP拍在了沙滩上
- spring-boot 代码生成工具
- 【数据结构】算法8.3 广义表遍历算法
- spring-boot集成sitemesh装饰器
- Discoverer
- spring-boot集成EasyUI和KindEditor
- poj3621 二分+spfa
- spring-boot集成Quartz
- 根据字段名称查询数据库表名
- 2017微软校园招聘笔试题