코드 생성기의 사용의 봄 부팅 플러스 배경 발판 급속한 발전 (X)

봄 부팅 플러스 코드 생성 발전기

코드 생성 콘텐츠

  • 봄 부팅 플러스 MyBatis로 플러스 기준, 새로운 PARAM / VO 템플릿 등의
  • 컨트롤러 / 서비스 / 매퍼 / XML을 확장 일반적인 CRUD / 페이징을 생성
  • 코드 생성 템플릿 : 봄 부팅 플러스 / SRC / 테스트 / 자원 / 템플릿

목적

새로운 데이터베이스 테이블은 자신감뿐만 아니라, 배경 CRUD / 페이징 코드베이스를 생성 할 수 있습니다!

공식 웹 사이트 주소 : springboot.plus
GitHub의 : https://github.com/geekidea/spring-boot-plus
GITEE : https://gitee.com/geekidea/spring-boot-plus
                 _                    _                 _                _
                (_)                  | |               | |              | |
  ___ _ __  _ __ _ _ __   __ _ ______| |__   ___   ___ | |_ ______ _ __ | |_   _ ___
 / __| '_ \| '__| | '_ \ / _` |______| '_ \ / _ \ / _ \| __|______| '_ \| | | | / __|
 \__ \ |_) | |  | | | | | (_| |      | |_) | (_) | (_) | |_       | |_) | | |_| \__ \
 |___/ .__/|_|  |_|_| |_|\__, |      |_.__/ \___/ \___/ \__|      | .__/|_|\__,_|___/
     | |                  __/ |                                   | |
     |_|                 |___/                                    |_|

      :: Spring Boot ::             (v2.1.6.RELEASE)
      :: Spring Boot Plus ::        (v1.0.0.RELEASE)

코드 생성 단계

  1. 예를 들어, 데이터베이스 테이블을 만듭니다 sys_log를

    참고 : 코멘트 테이블을 추가해야합니다, 열 필드가 생성 클래스의 의견을 용이하게하기 위해 노트, 자신감을 언급

-- ----------------------------
-- Table structure for sys_log
-- ----------------------------
DROP TABLE IF EXISTS `sys_log`;
CREATE TABLE `sys_log`  (
  `log_id` bigint(18) NOT NULL COMMENT '主键',
  `type` tinyint(1) NULL DEFAULT NULL COMMENT '类型',
  `content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '内容',
  `create_id` bigint(18) NULL DEFAULT NULL COMMENT '创建人ID',
  `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`log_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统日志' ROW_FORMAT = Dynamic;
  1. 구성 코드 생성
spring-boot-plus/src/test/java/io/geekidea/springbootplus/test/CodeGenerator.java

코드 생성기의 위치

2.1 연결 구성 데이터베이스를 수정

private static final String USER_NAME = "root";
private static final String PASSWORD = "rootroot";
private static final String DRIVER_NAME = "com.mysql.jdbc.Driver";
private static final String DRIVER_URL = "jdbc:mysql://localhost:3306/spring_boot_plus?useUnicode=true&characterEncoding=UTF-8&useSSL=false";

2.2 모듈, 테이블 및 기타 구성 작가를 수정

// ############################ 配置部分 start ############################
// 模块名称
private static final String MODULE_NAME = "system";
// 作者
private static final String AUTHOR = "geekidea";
// 生成的表名称
private static final String TABLE_NAME = "sys_log";
// 主键数据库列名称
private static final String PK_ID_COLUMN_NAME = "log_id";
// 代码生成策略 true:All/false:SIMPLE
private static final boolean GENERATOR_STRATEGY = true;
// 分页列表查询是否排序 true:有排序参数/false:无
private static final boolean PAGE_LIST_ORDER = true;
// ############################ 配置部分 end ############################
  • MODULE_NAME : 모듈 이름, 별도의 폴더의 형태로 구현 현재 프로젝트
  • 저자 : 저자 이름, 주석 클래스에 반영
  • TABLE_NAME 표 이름, 표 이름 등, 현재의 엔티티와 연관된 생성 할 필요
  • PK_ID_COLUMN_NAME : 기본 키 열 이름, 기본 ID는, 다른 이름, 여기 구성 할 수 있습니다
  • / 모든 거짓 : GENERATOR_STRATEGY : 사실 코드 생성 전략 SIMPLE
  • PAGE_LIST_ORDER : 페이지 목록 쿼리 여부를 정렬 사실 : / 일종의 매개 변수 거짓이 없습니다 : 없음
  1. 실행 CodeGenerator.java

    로그를 생성하기 위해 3.1 콘솔 출력

11:33:43.442 [main] DEBUG com.baomidou.mybatisplus.generator.AutoGenerator - ==========================准备生成文件...==========================
11:33:44.167 [main] DEBUG com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine - 创建目录: [E:\github\spring-boot-plus/src/main/java\io\geekidea\springbootplus\system\entity]
11:33:44.169 [main] DEBUG com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine - 创建目录: [E:\github\spring-boot-plus/src/main/java\io\geekidea\springbootplus\system\web\controller]
11:33:44.170 [main] DEBUG com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine - 创建目录: [E:\github\spring-boot-plus/src/main/java\io\geekidea\springbootplus\system\service]
11:33:44.170 [main] DEBUG com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine - 创建目录: [E:\github\spring-boot-plus/src/main/java\io\geekidea\springbootplus\system\mapper]
11:33:44.171 [main] DEBUG com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine - 创建目录: [E:\github\spring-boot-plus/src/main/java\io\geekidea\springbootplus\system\service\impl]
...
11:33:44.294 [main] DEBUG org.apache.velocity - ResourceManager : found /templates/mapper.xml.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
11:33:44.308 [main] DEBUG com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine - 模板:/templates/mapper.xml.vm;  文件:E:\github\spring-boot-plus/src/main/resources/mapper/system/SysLogMapper.xml
11:33:44.313 [main] DEBUG org.apache.velocity - ResourceManager : found /templates/queryParam.java.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
11:33:44.314 [main] DEBUG com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine - 模板:/templates/queryParam.java.vm;  文件:E:\github\spring-boot-plus/src/main/java/io/geekidea/springbootplus/system/web/param/SysLogQueryParam.java
11:33:44.332 [main] DEBUG org.apache.velocity - ResourceManager : found /templates/queryVo.java.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
11:33:44.337 [main] DEBUG com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine - 模板:/templates/queryVo.java.vm;  文件:E:\github\spring-boot-plus/src/main/java/io/geekidea/springbootplus/system/web/vo/SysLogQueryVo.java
11:33:44.347 [main] DEBUG org.apache.velocity - ResourceManager : found /templates/entity.java.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
11:33:44.357 [main] DEBUG com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine - 模板:/templates/entity.java.vm;  文件:E:\github\spring-boot-plus/src/main/java\io\geekidea\springbootplus\system\entity\SysLog.java
11:33:44.359 [main] DEBUG org.apache.velocity - ResourceManager : found /templates/mapper.java.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
11:33:44.360 [main] DEBUG com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine - 模板:/templates/mapper.java.vm;  文件:E:\github\spring-boot-plus/src/main/java\io\geekidea\springbootplus\system\mapper\SysLogMapper.java
11:33:44.362 [main] DEBUG org.apache.velocity - ResourceManager : found /templates/service.java.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
11:33:44.364 [main] DEBUG com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine - 模板:/templates/service.java.vm;  文件:E:\github\spring-boot-plus/src/main/java\io\geekidea\springbootplus\system\service\SysLogService.java
11:33:44.367 [main] DEBUG org.apache.velocity - ResourceManager : found /templates/serviceImpl.java.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
11:33:44.369 [main] DEBUG com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine - 模板:/templates/serviceImpl.java.vm;  文件:E:\github\spring-boot-plus/src/main/java\io\geekidea\springbootplus\system\service\impl\SysLogServiceImpl.java
11:33:44.373 [main] DEBUG org.apache.velocity - ResourceManager : found /templates/controller.java.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
11:33:44.376 [main] DEBUG com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine - 模板:/templates/controller.java.vm;  文件:E:\github\spring-boot-plus/src/main/java\io\geekidea\springbootplus\system\web\controller\SysLogController.java
11:33:44.376 [main] DEBUG com.baomidou.mybatisplus.generator.AutoGenerator - ==========================文件生成完成!!!==========================

Process finished with exit code 0

3.2 모듈 및 패킷 구조를 생성

├─system                模块包
│  ├─entity             实体类包
│  ├─mapper             mybatis mapper接口包
│  ├─service            服务接口包
│  │  └─impl            服务实现包
│  └─web                提供前端结果相关包
│      ├─controller     控制器包
│      ├─param          参数包
│      └─vo             值对象,响应结果包

3.3 패킷 생성과 관련된 클래스

├─system                                
│  ├─entity                             
│  │      SysLog.java                   实体类,已生成swagger注释
│  ├─mapper                             
│  │      SysLogMapper.java             mapper接口
│  ├─service                            
│  │  │  SysLogService.java             服务接口,已继承公共service
│  │  └─impl                            
│  │          SysLogServiceImpl.java    服务实现类,已继承公共service impl
│  └─web                                
│      ├─controller                     
│      │      SysLogController.java     控制器类,已生成CRUD,分页controller方法,已生成swagger文档
│      ├─param                                                
│      │      SysLogQueryParam.java     请求参数类,用于条件分页查询等
│      └─vo                             
│              SysLogQueryVo.java       响应结果类,用于自定义查询响应结果等

시작 항목

SpringBootPlusApplication.java
2019-07-27 12:11:45.298  INFO 21856 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8888 (http) with context path ''
2019-07-27 12:11:45.301  INFO 21856 --- [           main] i.g.s.SpringBootPlusApplication          : Started SpringBootPlusApplication in 9.66 seconds (JVM running for 10.988)
2019-07-27 12:11:45.304  INFO 21856 --- [           main] i.g.s.util.PrintApplicationInfo          : projectFinalName : spring-boot-plus
2019-07-27 12:11:45.305  INFO 21856 --- [           main] i.g.s.util.PrintApplicationInfo          : projectVersion : 1.0.0.RELEASE
2019-07-27 12:11:45.305  INFO 21856 --- [           main] i.g.s.util.PrintApplicationInfo          : profileActive : local
2019-07-27 12:11:45.305  INFO 21856 --- [           main] i.g.s.util.PrintApplicationInfo          : contextPath : /
2019-07-27 12:11:45.305  INFO 21856 --- [           main] i.g.s.util.PrintApplicationInfo          : port : 8888
2019-07-27 12:11:45.308  INFO 21856 --- [           main] i.g.s.util.PrintApplicationInfo          : home:http://192.168.1.168:8888/
2019-07-27 12:11:45.308  INFO 21856 --- [           main] i.g.s.util.PrintApplicationInfo          : docs:http://192.168.1.168:8888/docs
2019-07-27 12:11:45.308  INFO 21856 --- [           main] i.g.s.util.PrintApplicationInfo          : spring-boot-plus project start success...........
2019-07-27 12:11:45.309  INFO 21856 --- [           main] i.g.s.util.PrintApplicationInfo          : 
 ____    __                    __        ____                                                   
/\  _`\ /\ \__                /\ \__    /\  _`\                                                 
\ \,\L\_\ \ ,_\    __     _ __\ \ ,_\   \ \,\L\_\  __  __    ___    ___     __    ____    ____  
 \/_\__ \\ \ \/  /'__`\  /\`'__\ \ \/    \/_\__ \ /\ \/\ \  /'___\ /'___\ /'__`\ /',__\  /',__\ 
   /\ \L\ \ \ \_/\ \L\.\_\ \ \/ \ \ \_     /\ \L\ \ \ \_\ \/\ \__//\ \__//\  __//\__, `\/\__, `\
   \ `\____\ \__\ \__/.\_\\ \_\  \ \__\    \ `\____\ \____/\ \____\ \____\ \____\/\____/\/\____/
    \/_____/\/__/\/__/\/_/ \/_/   \/__/     \/_____/\/___/  \/____/\/____/\/____/\/___/  \/___/ 

Access 프로젝트

에 http : // localhost를 : 8888 / 자신감-ui.html

또는 로컬 IP를 방문

http://192.168.xxx.xxx:8888/swagger-ui.html

  • 자신감의 CRUD의 자동 생성, 페이지 매김 인터페이스 문서
    멋진
  1. 인터페이스 자신감을 추가 추가
    인터페이스 자신감을 추가 추가

  2. 인터페이스 자신감을 삭제합니다
    인터페이스 자신감을 삭제합니다

  3. getPageList 페이징 인터페이스 자신감
    getPageList 페이징 인터페이스 자신감

  4. 세부 인터페이스 자신감 정보
    세부 인터페이스 자신감 정보

  5. 인터페이스 자신감을 수정으로 업데이트
    인터페이스 자신감을 수정으로 업데이트

추천

출처www.cnblogs.com/springbootplus/p/11334671.html