spring-cloud-dependencies 版本列表可查看:
https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-dependencies
spring-boot-starter-parent 版本列表可查看:
https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent
spring官网:
点击SpringCloud往下拉,可以查看SpringCloud和Springboot对应版本
到spring官方下载最新的springboot 与 springcloud版本对应代码example: https://start.spring.io/
前置环境,安装jdk,idea,maven环境
第一步:
在idea中新建一个maven项目
这里面我假定做一个学生管理系统,叫做studentmanage的系统:
这里面我默认选择的jdk是11
第二步:
开始添加各子模块:
在这里面我需要做几个模块,分别为studentmanage-task,studentmanage-rpc,studentmanage-mq,studentmanage-web.
基本的maven结构创建完毕。
第三步:
编辑根pom文件:
接下来开始编辑父pom文件。
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.9.RELEASE</version> </parent> <properties> <java.version>11</java.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> </properties> <dependencies> </dependencies> <dependencyManagement> </dependencyManagement> <build> <plugins> </plugins> </build>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.9.RELEASE</version>
</parent>
这一句,点开里面的内容,可以看到这里面定义了依赖的版本,所以后续相关依赖,不需要再定义版本号,玄机就在这里。
1):选择springboot的版本
关于springboot的版本号选择,参考下面网站:
https://mvnrepository.com/artifact/org.springframework.boot/spring-boot
2):maven仓库相关仓库服务 (aliyun.com)https://developer.aliyun.com/mvn/view
此时再看项目,2.5.5版本已经引入:
。
顺便贴一下我的maven中配置的镜像地址:
接下来开始在根pom文件,引入其他的依赖:
第四步:
在studentmanage-web目录中添加springboot的web依赖,添加主启动类,添加配置文件
可以看到已经启动成功了。