一.为什么会想到定义@SpringCloudProfile这样的注解 首页提一下@Profile注解:它主要用与Spring Boot多环境配置中,指定某个类只在指定环境中生效,比如swagger的配置只允许开发和测试环境开发,线上需要禁止使用. 使用@Profile进行如下配置: @Configuration @EnableSwagger2@Profile({"dev", "test"}) public class Swagger2Config { @Bean p
Spring Cloud针对Environment的属性源功能做了增强, 在spring-cloud-contenxt这个包中,提供了PropertySourceLocator接口,用来实现属性文件加载的扩展.我们可以通过这个接口来扩展自己的外部化配置加载.这个接口的定义如下 public interface PropertySourceLocator { /** * @param environment The current Environment. * @return A Property
在使用服务发现的时候有两种注解, 一种为@EnableDiscoveryClient, 一种为@EnableEurekaClient, 用法上基本一致,下文是从stackoverflow上面找到的对这两者的解释: There are multiple implementations of "Discovery Service" (eureka, consul, zookeeper). @EnableDiscoveryClient lives in spring-cloud-common
使用服务发现的时候提到了两种注解,一种为@EnableDiscoveryClient,一种为@EnableEurekaClient,用法上基本一致,今天就来讲下两者,下文是从stackoverflow上面找到的对这两者的解释: There are multiple implementations of "Discovery Service" (eureka, consul, zookeeper). @EnableDiscoveryClient lives in spring-cloud
Spring AOP的主要功能相信大家都知道,日志记录.权限校验等等. 用法就是定义一个切入点(Pointcut),定义一个通知(Advice),然后设置通知在该切入点上执行的方式(前置.后置.环绕等). 只不过一直没想过切入点还可以是注解. 下面直接进入节奏 1.打开STS,新建一个Spring Starter Project.如果不清楚STS是什么,可以参考我的 Spring Tools Suite (STS) 简介,几分钟的事. Starter模块选择web.aop,其实我还选了一个Dev