当前位置:网站首页>微服务项目搭建三:自动生成代码
微服务项目搭建三:自动生成代码
2022-06-13 08:10:00 【梦.之.蓝】
1,观点论述
自动生成代码的插件是很多的,比如easyCode,最近看到的谷粒商城的自制的renren-generator,比如mybatis-plus的mybatis-generator,不过在经过评估以后,我认为使用mybatisX来按需生成代码是最合适的。
2,操作步骤:
1,安装mybatisX插件,新建一个springcloud项目,并且,要注意,后续要用到分布式事务,所以要注意seata框架和springcloud版本要对照

注意,在这里,我的jdk的版本为17,原因是jdk17如果开启ZGC的话,在GC处理的效率来说,会比普通的GC会好的多,它是在产生垃圾的同时,会有线程回去处理垃圾,而且,在这里,就不会出现新生代,老年代的说法了,在这里,会把垃圾分成不同的块状空间,并优先处理大块的空间的垃圾,所以,在开启ZGC的时候,在运行项目的同时,会有垃圾线程在回收垃圾。
参考:
阿里云中的maven仓库地址:仓库服务https://developer.aliyun.com/mvn/guide
2,删除多余文件
结果如下:

3,在pom.xml文件添加相关依赖,结果如下
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- 公共依赖-->
<modules>
<module>course-main</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.8</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.mengzhilan</groupId>
<artifactId>course</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>course</name>
<description>course</description>
<properties>
<java.version>17</java.version>
<lombok.version>1.18.12</lombok.version>
<seata.version>1.5.1</seata.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<!--seata-->
<!-- <dependency>-->
<!-- <groupId>com.alibaba.cloud</groupId>-->
<!-- <artifactId>spring-cloud-alibaba-seata</artifactId>-->
<!-- <version>2.1.1.RELEASE</version>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <artifactId>seata-all</artifactId>-->
<!-- <groupId>io.seata</groupId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.seata</groupId>-->
<!-- <artifactId>seata-all</artifactId>-->
<!-- <version>${seata.version}</version>-->
<!-- </dependency>-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
4,新建子模块:

新建选择moudle,然后选择spring initializr
5,新建完后,删除多余的文件,结果如下所示

pom.xml文件为:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mengzhilan</groupId>
<artifactId>course</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.mengzhilan</groupId>
<artifactId>course-main</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>course-main</name>
<description>course-main</description>
<properties>
<spring-cloud.version>2021.0.3</spring-cloud.version>
<java.version>17</java.version>
</properties>
<dependencies>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
6,点击右侧的Databse,连接数据库

7,生成代码,并放入到项目文件夹中,最终结果如下所示

8,在这里,我列举下我使用的版本
springboot :2.6.8
springcloud:2021.0.3
seata-all:1.5.1
spring-cloud-alibaba-seata: 2.1.1
9,至此,自动生成代码就配置好了,后续按需编写对应的代码。
边栏推荐
- [pytorch] pytorch0.4.0 installation tutorial and GPU configuration collection (including test code)
- Practice makes sense -- your byte alignment and stack cognition may be wrong
- 2022年G3锅炉水处理操作证考试题库模拟考试平台操作
- [MySQL] online lock free delay free DDL artifact GH OST
- Tidb source code series: immersive compilation of tidb
- 判断一个字符串是否由另外一个字符串旋转而来
- Clickhouse column basic data type description
- 20 | pipeline oriented instruction design (Part 1): Modern CPU with multi-purpose
- ERP基础数据 金蝶
- Recognition of COVID-19 based on paddlepaddle
猜你喜欢
![[pytorch] pytorch0.4.0 installation tutorial and GPU configuration collection (including test code)](/img/b4/138b7ae8c73e38663ea84ece79273b.jpg)
[pytorch] pytorch0.4.0 installation tutorial and GPU configuration collection (including test code)

JMeter UDP pressure measurement

免费文件服务器储存技术

ERP 基础数据 概念

本地靶场2-文件上传漏洞(三)-网络安全

母婴用品批发行业使用管理软件提高效率 实现降本增效

BD新标签页(BdTab)插件如何登入?

MySQL table partitioning

Create a substrate private network

26 | superscalar and VLIW: how to make the CPU throughput exceed 1
随机推荐
Remote office solution under epidemic situation
Word中批注的使用方法
23 | adventure and prediction (II): relay race in the assembly line
2022年G3锅炉水处理操作证考试题库模拟考试平台操作
set实现名单查找与排除
将solidworks建的机器人模型导入到ros中
批发商为什么要使用订单系统
2022 simulated examination question bank and online simulated examination of hoisting machinery command examination questions
JMeter UDP pressure measurement
leetcode 咒语和药水的成功对数
19 | establish data path (bottom): instruction + operation =cpu
实践出真知--你的字节对齐和堆栈认知可能是错误的
Selenium reports an error deprecationwarning: executable_ path has been deprecated, please pass in a Service object
Get properties of class
4. fabric2.2 create and join channels (use the official demo)
19 | 建立数据通路(下):指令+运算=CPU
Effective Go - The Go Programming Language
Data warehouse data processing and data flow
Install cuda+cusp environment and create the first helloword starter project
疫情之下的远程办公解决方案