一、建一个springboot项目,直接用ide的spring初始化模板项目就行。
![0](https://img2022.cnblogs.com/blog/1058222/202203/1058222-20220304095729938-314651378.jpg)
二、修改一下pom依赖,一个是引入springcloud-alibaba相关的包,还有个原因上面这种模板建的项目一般用的是最新的springboot版本包,可能maven镜像没有,根据提示修改就可以了。
<?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>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.9.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.ll</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <name>demo</name> <description>demo for springcloud alibaba</description> <properties> <java.version>1.8</java.version> <com-alibaba-cloud.version>2.2.5.RELEASE</com-alibaba-cloud.version> <nacos.version>2.2.3.RELEASE</nacos.version> </properties> <dependencies> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <exclusions> <exclusion> <artifactId>jsr305</artifactId> <groupId>com.google.code.findbugs</groupId> </exclusion> </exclusions> <version>${nacos.version}</version> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> <version>${nacos.version}</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
修改完成后,在这里因为springcloud-alibaba是springcloud改造项目,肯定是依赖springboot相关包的,这里就不重复引入。
![0](https://img2022.cnblogs.com/blog/1058222/202203/1058222-20220304095730653-251572756.jpg)
三、建子项目,要撺个大活儿,那就刚好把没接触过的网关和别的玩一下,来一整套,建个网关微服务子项目,后面其他子项目一样操作:
![0](https://img2022.cnblogs.com/blog/1058222/202203/1058222-20220304095730969-1606348316.jpg)
![0](https://img2022.cnblogs.com/blog/1058222/202203/1058222-20220304095730777-909625489.jpg)
四、安装nacos,安装前置条件,已安装java maven,这些就不说了,这用配置和注册中心也就齐活儿了,可以开始撸码了。