springCloud 2.0 不同之处

 

1:在实现对应的客户端的获取pom时候的配置

此处是必须的依赖的配置属性

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-netflix-eureka-client</artifactId>
    <version>2.1.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
    <version>2.1.1.RELEASE</version>

 

2:对于web情况必须的配置属性

 

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

 3:  实现对于服务登录密码实现对应的配置

1: pom配置

实现包,主要每个使用的版本信息,因为可能会会包之间版本冲突导致的问题,像webInter***找不到问题

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
    <version>2.1.4.RELEASE</version>
</dependency>

 

2: 对于登录的时候的配置:

spring.security.user.name=admin
spring.security.user.password=admin 

以上部分网上说不用配置密码,但是还是需要配置,否则直接访问接口的时候使用没有密码发现根本访问不了。

以下 部分 :此处可能实现客户端注册的时候去除密码登录的的功能吧,没有它服务注册不上去。

@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable();
        super.configure(http);
    }
}

对于post请求需要注意事项

@RequestMapping(value = "/tblStatisticsRegion/region", method = RequestMethod.POST,consumes = "application/json")
public DataReturnResult riskTypeStatistics(@RequestBody(required = false) TblStatisticsVo tblStatisticsVo);

 

3:zuul 实现配置匹配可能的坑:

注意:匹配规则 对于的访问就是eureka-client01 中hi?name=forezp&token=22  访问地址数据

zuul.routes.client.path=/api-a/**
zuul.routes.client.service-id=eureka-client01

http://localhost:8769/api-a/hi?name=forezp&token=22 

<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-zuul</artifactId>
</dependency>

4:熔断器使用

  1: 使用feign调用时候需要 

feign.hystrix.enabled=true 开启服务实现否则不能用

  2:一种是方法的上面切面降级不用开启。

 3:

 

 

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值