服务提供者:provider
server:
port: 8081
#数据库连接信息
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/boot?useSSL=false&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8
username: root
password: 123456
application:
name: service-provider #将来会作为微服务的名称
#配置mybatis信息,pojo别名扫描包
mybatis:
type-aliases-package: com.ly.domain
eureka:
client:
service-url:
defaultZone: http://localhost:10086/eureka
register-with-eureka: true #默认值为true,服务提供方启动时,会检测该参数是否为true,true-注册给eureka
instance:
lease-renewal-interval-in-seconds: 5 #心跳时间
lease-expiration-duration-in-seconds: 15 #过期时间
服务调用者:consumer
server:
port: 8088
spring:
application:
name: service-consumer #将来会作为微服务的名称
eureka:
client:
service-url:
defaultZone: http://localhost:10086/eureka
fetch-registry: true #是否拉取服务,默认为true
registry-fetch-interval-seconds: 5 #拉取服务的间隔时间
service-provider:
ribbon:
NFLoadBalancerRuleClassName: com.netflix.loadbalancer.RandomRule
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 6000 #设置hystrix的超时时间为6000ms
feign:
hystrix:
enabled: true #开启Feign的熔断功能
Eureka服务注册中心:
server:
port: 10086
spring:
application:
name: ly-eureka #将来会作为微服务名称注入到eureka容器
eureka:
client:
service-url:
defaultZone: http://localhost:${server.port}/eureka
#server:
#eviction-interval-timer-in-ms: 5000 #失效剔除时间,单位毫秒
#enable-self-preservation: false #关闭自我保护状态
Zuul网关:
server:
port: 10010
spring:
application:
name: ly-zuul
#zuul: #路由配置方式1
#routes:
#service-provider:
#path: /service-provider/**
#url: http://localhost:8081
#zuul: #路由配置方式2
#routes:
#service-provider:
#path: /service-provider/**
#serviceId: service-provider
zuul: #路由配置方式3,推荐
routes:
service-provider: /provider/**
service-consumer: /consumer/**
prefix: /api
eureka:
client:
service-url:
defaultZone: http://localhost:10086/eureka
启动器相关:
<!--web启动器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- mybatis启动器 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.4</version>
</dependency>
<!-- 通用Mapper启动器 -->
<dependency>
### 笔者福利
##### 以下是小编自己针对马上即将到来的金九银十准备的一套“面试宝典”,不管是技术还是HR的问题都有针对性的回答。
**有了这个,面试踩雷?不存在的!**
##### **[CodeChina开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频】](https://codechina.csdn.net/m0_60958482/java-p7)**
##### 回馈粉丝,诚意满满!!!
![](https://img-blog.csdnimg.cn/img_convert/708d4b175dac64861e53d09bdbbb139e.png)
![](https://img-blog.csdnimg.cn/img_convert/541342a4477c3b36b6ae8578c5d80331.png)
![](https://img-blog.csdnimg.cn/img_convert/610677ce4fc6586452b3ec3aef0b8769.png)
*有了这个,面试踩雷?不存在的!**
##### **[CodeChina开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频】](https://codechina.csdn.net/m0_60958482/java-p7)**
##### 回馈粉丝,诚意满满!!!
[外链图片转存中...(img-jBPgTjjY-1630842502676)]
[外链图片转存中...(img-EqaUq2iV-1630842502677)]
[外链图片转存中...(img-xC6JsvuM-1630842502678)]
![](https://img-blog.csdnimg.cn/img_convert/5131d43a9636af0bdaccd501d43ca880.png)