# generate-crud-code **Repository Path**: guoguang0536/generate-crud-code ## Basic Information - **Project Name**: generate-crud-code - **Description**: No description available - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-08-04 - **Last Updated**: 2021-10-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 安装插件 idea插件市场搜索Generate Crud安装 # Generate_Crud_Code 根据实体类生成原始代码 在带有@Entity注解的实体类上右键单击"Generator CRUD",然后将生成以下模块: - Controller REST API with Swagger DOC API - DAO(JpaRepository) - DTO - Service (with page query) - Mapper mapstruct - Mockito Junit5 Unit Test 生成的DTO如果需要加验证,在@Column注解上定义columnDefinition属性和length属性 例如: ``` @Column(length = 100,columnDefinition = "not null") ``` DTO将生成如下字段 ``` @Size(max = 100) @NotBlank private String ipAddress; ``` ![image](https://yd-note.oss-cn-beijing.aliyuncs.com/%E4%B9%B1%E4%B8%83%E5%85%AB%E7%B3%9F/DEMO.gif) # note Controller层返回标准Result,生成后自己调整即可 ## pom.xml文件参考配置 ``` org.mapstruct mapstruct 1.4.2.Final org.apache.maven.plugins maven-compiler-plugin 3.8.1 1.8 1.8 org.mapstruct mapstruct-processor 1.4.2.Final org.springframework.boot spring-boot-maven-plugin org.apache.maven.plugins maven-surefire-plugin 2.22.0 src/main/java **/*.properties **/*.xml false src/main/resources true src/main/resources **/*.properties **/*.xml false ``` 生成文件后需要标记生成的文件为代码(src/generated-sources/java目录标记为Generated Sources Root) ![generated-sources标记为源码.png](https://vue-admin-guoguang.oss-cn-shanghai.aliyuncs.com/generated-sources%E6%A0%87%E8%AE%B0%E4%B8%BA%E6%BA%90%E7%A0%81.png) # 感谢 👤 **GuoGuang** 如果此项目帮到了你,还请不忘star哦🌟,你的关注是我的动力 # License [Apache-2.0](https://opensource.org/licenses/Apache-2.0) Copyright (c) 2021-present GuoGuang