自己做网站如何赚钱吗,短网址还原在线生成,品牌网站部门建设,网站建设准备资料表格首先要搭建注册中心服务端#xff1a;eureka-server#xff0c;这必须是一个独立的微服务
1.创建项目 创建maven工程即可
2.引入依赖
提示#xff1a;starter是springboot中的自动装配#xff0c;在这个依赖里#xff0c;已经帮我们把eureka的所有配置都做好了
de…首先要搭建注册中心服务端eureka-server这必须是一个独立的微服务
1.创建项目 创建maven工程即可
2.引入依赖
提示starter是springboot中的自动装配在这个依赖里已经帮我们把eureka的所有配置都做好了
dependencies!--eureka服务端不需要写版本信息因为在父工程中已经把这些依赖的版本都管理好了--dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-netflix-eureka-server/artifactId/dependency
/dependencies
3.编写启动类 这种自动装配是需要开关的故需要添加EnableEurekaServer注解
package cn.itcast.eureka;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;/*** author 温柔哥* create 2024-01-16 20:33*/
EnableEurekaServer // 自动装配的开关
SpringBootApplication
public class EurekaApplication {public static void main(String[] args) {SpringApplication.run(EurekaApplication.class, args);}
}
4.编写配置 添加application.yml文件
server:port: 10086 # 服务端口随便起# --------------服务注册---------------
# 因为eureka-server也是一个微服务所以也需要注册
spring:application:name: eurekaserver #eureka的服务名称
eureka:client:service-url: # eureka的地址信息这是用来eureka集群内他们相互交流配置的defaultZone: http://127.0.0.1:10086/eureka # 如果有多个的话用逗号分隔开
5.启动验证 访问成功
Eurekahttp://localhost:10086/