https://www.jianshu.com/p/a40219751264
添加依赖包
<!--加入服务认证(密码),需要引入security-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
配置文件 application.yml
2.0版本配置方法(注意:与旧版配置不同)
server:
port: 8100
eureka:
instance:
hostname: localhost
client:
# 由于该应用为注册中心,所以设置为false,代表不向注册中心注册自己
register-with-eureka: false
# 由于注册中心的职责就是维护服务示例,它并不需要去检索服务,所以也设置为false
fetch-registry: false
serviceUrl:
defaultZone: http://name:pwd@${eureka.instance.hostname}:${server.port}/eurek