3.eureka
1.导入相关的依赖--注意版本关系
修改完版本号,有时候更新过慢
可以rebulier project
新建module,导入jar报后配置注解
导入jar包
注意版本间的关系
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
配置application
server:
port: 7001
# Eureka配置
eureka:
instance:
hostname: localhost # Eureka服务端名称
client:
register-with-eureka: false # false表示注册自己
fetch-registry: false
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
开启服务后,访问7001端口
服务端注册到Eureka
导入Eureka
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
<version>1.4.5.RELEASE</version>
</dependency>
<!-- 完善监控-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
application中的eureka配置
# Eureka配置
eureka:
client:
service-url:
defaultZone: http://localhost:7001/eureka/
instance:
instance-id: springcloud-provider-dept8001
info:
app.name: chuan-springcloud
company.name: blog.chuanstudy.com
加上注解
访问7001
注册陈宫