网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
public static final String PREFIX = "spring.cloud.gateway";
private final Log logger = LogFactory.getLog(getClass());
@NotNull
@Valid
private List<RouteDefinition> routes = new ArrayList<>();
private List<FilterDefinition> defaultFilters = new ArrayList<>();
private List<MediaType> streamingMediaTypes = Arrays.asList(MediaType.TEXT_EVENT_STREAM,
MediaType.APPLICATION_STREAM_JSON);
private boolean failOnRouteDefinitionError = true;
}
`routes`也就是`List`对象类:
@Validated
public class RouteDefinition {
private String id;
@NotEmpty
@Valid
private List<PredicateDefinition> predicates = new ArrayList<>();
@Valid
private List<FilterDefinition> filters = new ArrayList<>();
@NotNull
private URI uri;
private Map<String, Object> metadata = new HashMap<>();
private int order = 0;
}
`yaml`里的配置:
spring:
cloud:
gateway:
routes:
- id: gateway-service-1
uri: https://www.baidu.com
predicates:
- Path=/searchBaidu/**
filters:
- CacheRequestFilter
- ValidateCodeFilter
- StripPrefix=1
- /authmxl/uklogin
- id: gateway-service-2
uri: https://www.google.com
predicates:
- Path=/searchGoogle/**
filters:
- CacheRequestFilter
- ValidateCodeFilter
- StripPrefix=1
- /authmxl/uklogin
#### 1.2 效仿一下
配置类:
@Data
@Component
@ConfigurationProperties(TranslateConfiguration.PREFIX)
public class TranslateConfiguration {
public static final String PREFIX = "translate";
private List<TranslateConfig> config= new ArrayList<>();
@Data
public static class TranslateConfig {
private String type;
private int open;
private String fromUrl;
private String fromPort;
private String toUrl;
private String toPort;
}
}
`yaml`参数:
translate:
config:
- type: jafka-jafka
open: 1
fromUrl: 192.168.0.1
fromPort: 9092
toUrl: 192.168.0.2
toPort: 9092
- type: kafka-jafka
open: 0
fromUrl: 192.168.0.2
fromPort: 9092
toUrl: 192.168.0.1
toPort: 9092
### 2.DynamicDataSource
#### 2.1 查看源码
// 这里只贴出 datasource 也就是 Map 对象
public class DynamicDataSourceProperties {
private Map<String, DataSourceProperty> datasource;
}
// Map 里的 Value 对象
public class DataSourceProperty {
private String driverClassName;
private String url;
private String username;
private String password;
`yaml`配置:
![img](https://img-blog.csdnimg.cn/img_convert/6a338ac1ed60c5a1feee3cab15a6f132.png)
![img](https://img-blog.csdnimg.cn/img_convert/9899fef7eab00d96ff749af969ea1eec.png)
![img](https://img-blog.csdnimg.cn/img_convert/ea7e16c70296e9f8177ae2b2452860fb.png)
**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!**
**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**
**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**
学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!**
**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**
**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**