spring-cloud 简单配置

我是用的版本是
Spring-Boot: 2.0.1 Re
Spring-Cloud : Greenwich.RC2

配置文件 application.yml
文件中主要配置 Eureka 、Config 、 Zuul 、 Security-Base-Auth

server:
  port: 3000


spring:
  application:
    name: lostfound-config-server

###-----------------------------------------------eureka   
eureka:
  instance:
    hostname: localhost
    appname: ${spring.application.name}
    instance-id: ${eureka.instance.hostname}:${server.port}
    ### spring cloud bus + spring boot actuator 用于向服务发送消息
    index: 9012
    ### 客户端心跳时间和剔除时间
    lease-renewal-interval-in-seconds: 1
    lease-expiration-duration-in-seconds: 5
  client:
    register-with-eureka: false
    ### 是否拉取各服务列表信息
    fetch-registry: false
    service-url:
      defaultZone: http://admin:admin@localhost:8000/eureka/
  ### 服务端开发模式下关闭自我保护机制
  server:
    enable-self-preservation: false
    eviction-interval-timer-in-ms: 5000
    

###-----------------------------------------------spring cloud config
spring:
  cloud:
    config:
      server:
        git:
          uri: https://gitee.com/YardStrong/spring-cloud-lostfound-config
          username: yardstrong@163.com
          password: ****************
          ### 配置文件存放路径,可以按照服务来划分目录
          search-paths: 
          - citizens-service
          - goods-service
      label: master
      
      
     
###-----------------------------------------------zuul
zuul:
  ### 解决重定向问题
  add-host-header: true
  routes:
    api-citizens:
      path: /api-citizens/**
      service-id: citizens-service
    api-goods:
      path: /api-goods/**
      service-id: goods-service
      ### 避免敏感请求头被过滤 - 方法1
#      sensitive-headers: 
      ### 避免敏感请求头被过滤 - 方法2
#      custom-sensitive-headers: false
    ### url 模式
#    api-test:
#      path: /api-test/**
#      url: http://localhost:999/

    ### 另一种方式  <service-id>: <path>
#    citizens-service: /api-citizens/**
#    goods-service: /api-goods/**

    ### 不适用eureka:
#ribbon:
#  eureka:
#    enabled: false
#api-citizens:
#  ribbon:
#    listOfServers: 
#    - http://192.168.1.101:8010/
#    - http://192.168.1.102:8010/

其中Eureka-Server服务使用了base-auth认证

@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

	@Override
	protected void configure(HttpSecurity http) throws Exception {
		http.csrf().disable();
		http.authorizeRequests().anyRequest().authenticated().and().httpBasic();
		super.configure(http);
	}
	
}

Spring Boot 简单配置

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值