1.创建SpringBoot项目
2.删除不需要的,留一个pom文件
3.调低SpringBoot的版本: <version>2.1.6.RELEASE</version>
4.导入该pom文件
<dependencies> <!-- SpringBoot启动器--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <!-- SpringBoot测试启动器--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- Web依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- 日志依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </dependency> <!-- Lombok工具 --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.4</version> <scope>provided</scope> </dependency> <!-- Actuator可以帮助你监控和管理Spring Boot应用 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <!-- 热部署 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> </dependencies>
5.新建一个微服务的项目
6.在该服务下导入jar包
<dependencies> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.3.2</version> </dependency> <!-- pojo持久化使用 --> <dependency> <groupId>javax.persistence</groupId> <artifactId>javax.persistence-api</artifactId> <version>2.2</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> </dependencies>
到这里我们的微服务架构就基本搭建好了
在SpringBoot中搭建微服务的项目(19版)
于 2023-07-10 15:47:01 首次发布
本文详细介绍了如何创建一个SpringBoot项目,包括删除不必要的文件,降低SpringBoot版本到2.1.6.RELEASE,然后逐步导入所需的依赖,如SpringBoot启动器、Web支持、日志、Lombok、Actuator和热部署工具。接着,创建一个微服务项目,并添加MyBatis-Plus、JPA和MySQL数据库连接的支持,完成了微服务的基本架构搭建。
摘要由CSDN通过智能技术生成