2-1 使用Eureka搭建注册中心
1.生成Spring Boot项目
在Spring initializr网站生成项目
Spring Boot版本号任选,然后在项目中改成【2.2.2.RELEASE】
以及【Hoxton.RELEASE】
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
...
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>
</properties>
2.改造成多个Maven子项目
项目右键-New-Module
把父模块pom文件中的依赖放到eureka的pom中
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
在eureka的java创建com.course,把父项目中的CourseApplication拷过去,改名成EurekaApplication
删除父模块的src目录