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: