mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
add branch 1.x, support spring boot 1.x
This commit is contained in:
parent
c4cbbf41e2
commit
ee2f75cea8
@ -46,7 +46,7 @@ As the interfaces and annotations of Spring Boot 1 and Spring Boot 2 have been c
|
|||||||
* 0.2.x for Spring Boot 2
|
* 0.2.x for Spring Boot 2
|
||||||
|
|
||||||
During the incubation period,the version management of the project will follow these rules:
|
During the incubation period,the version management of the project will follow these rules:
|
||||||
* Functional updates will be reflected in the 3rd number of the version, for example, the next version of 0.1.0 will be 0.1.1。
|
* Functional updates will be reflected in the 3rd number of the version, for example, the next version of 0.1.0 will be 0.1.1 .
|
||||||
* Emergency fixes for bugs that block the main business process will be reflected in version numbers such as 0.1.1.fix. However, it is our duty to improve the test regression process to avoid such scenarios.
|
* Emergency fixes for bugs that block the main business process will be reflected in version numbers such as 0.1.1.fix. However, it is our duty to improve the test regression process to avoid such scenarios.
|
||||||
|
|
||||||
|
|
||||||
|
15
pom.xml
15
pom.xml
@ -8,13 +8,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-build</artifactId>
|
<artifactId>spring-cloud-build</artifactId>
|
||||||
<version>2.0.0.RELEASE</version>
|
<version>1.3.8.RELEASE</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba</artifactId>
|
<artifactId>spring-cloud-alibaba</artifactId>
|
||||||
<version>0.2.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0.BUILD-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>Spring Cloud Alibaba</name>
|
<name>Spring Cloud Alibaba</name>
|
||||||
|
|
||||||
@ -55,8 +55,8 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- Dependency Versions -->
|
<!-- Dependency Versions -->
|
||||||
<spring-cloud-commons.version>2.0.0.RELEASE</spring-cloud-commons.version>
|
<spring-cloud-commons.version>1.3.3.RELEASE</spring-cloud-commons.version>
|
||||||
<spring-cloud-netflix.version>2.0.0.RELEASE</spring-cloud-netflix.version>
|
<spring-cloud-netflix.version>1.4.4.RELEASE</spring-cloud-netflix.version>
|
||||||
|
|
||||||
<junit.version>4.12</junit.version>
|
<junit.version>4.12</junit.version>
|
||||||
<javax-servlet-api>3.0</javax-servlet-api>
|
<javax-servlet-api>3.0</javax-servlet-api>
|
||||||
@ -64,7 +64,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- Maven Plugin Versions -->
|
<!-- Maven Plugin Versions -->
|
||||||
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
|
<maven-compiler-plugin.version>3.5</maven-compiler-plugin.version>
|
||||||
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
|
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
|
||||||
<maven-surefire-plugin.version>2.21.0</maven-surefire-plugin.version>
|
<maven-surefire-plugin.version>2.21.0</maven-surefire-plugin.version>
|
||||||
<gmavenplus-plugin.version>1.6</gmavenplus-plugin.version>
|
<gmavenplus-plugin.version>1.6</gmavenplus-plugin.version>
|
||||||
@ -107,9 +107,8 @@
|
|||||||
<version>${maven-compiler-plugin.version}</version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<inherited>true</inherited>
|
<inherited>true</inherited>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.7</source>
|
||||||
<target>1.8</target>
|
<target>1.7</target>
|
||||||
<parameters>true</parameters>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>spring-cloud-dependencies-parent</artifactId>
|
<artifactId>spring-cloud-dependencies-parent</artifactId>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<version>2.0.0.RELEASE</version>
|
<version>1.3.3.BUILD-SNAPSHOT</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||||
<version>0.2.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0.BUILD-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>Spring Cloud Alibaba Dependencies</name>
|
<name>Spring Cloud Alibaba Dependencies</name>
|
||||||
<description>Spring Cloud Alibaba Dependencies</description>
|
<description>Spring Cloud Alibaba Dependencies</description>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba</artifactId>
|
<artifactId>spring-cloud-alibaba</artifactId>
|
||||||
<version>0.2.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0.BUILD-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
||||||
<version>0.2.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0.BUILD-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
spring.application.name=sentinel-example
|
spring.application.name=sentinel-example
|
||||||
server.port=18083
|
server.port=18083
|
||||||
management.endpoints.web.exposure.include=*
|
management.security.enabled=false
|
||||||
spring.cloud.sentinel.port=8721
|
spring.cloud.sentinel.port=8721
|
||||||
spring.cloud.sentinel.dashboard=localhost:8080
|
spring.cloud.sentinel.dashboard=localhost:8080
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba</artifactId>
|
<artifactId>spring-cloud-alibaba</artifactId>
|
||||||
<version>0.2.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0.BUILD-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -39,13 +39,6 @@
|
|||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
|
@ -71,8 +71,8 @@ public class SentinelWebAutoConfiguration {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnWebApplication
|
@ConditionalOnWebApplication
|
||||||
public FilterRegistrationBean<Filter> servletRequestListener() {
|
public FilterRegistrationBean servletRequestListener() {
|
||||||
FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<>();
|
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||||
|
|
||||||
SentinelProperties.Filter filterConfig = properties.getFilter();
|
SentinelProperties.Filter filterConfig = properties.getFilter();
|
||||||
|
|
||||||
|
@ -27,21 +27,23 @@ import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
|
|||||||
import com.alibaba.csp.sentinel.slots.system.SystemRule;
|
import com.alibaba.csp.sentinel.slots.system.SystemRule;
|
||||||
import com.alibaba.csp.sentinel.slots.system.SystemRuleManager;
|
import com.alibaba.csp.sentinel.slots.system.SystemRuleManager;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
|
||||||
import org.springframework.cloud.alibaba.sentinel.SentinelProperties;
|
import org.springframework.cloud.alibaba.sentinel.SentinelProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Endpoint for Sentinel, contains ans properties and rules
|
* Endpoint for Sentinel, contains ans properties and rules
|
||||||
* @author xiaojing
|
* @author xiaojing
|
||||||
*/
|
*/
|
||||||
@Endpoint(id = "sentinel")
|
public class SentinelEndpoint extends AbstractEndpoint<Map<String, Object>> {
|
||||||
public class SentinelEndpoint {
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SentinelProperties sentinelProperties;
|
private SentinelProperties sentinelProperties;
|
||||||
|
|
||||||
@ReadOperation
|
public SentinelEndpoint() {
|
||||||
|
super("sentinel");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Map<String, Object> invoke() {
|
public Map<String, Object> invoke() {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
package org.springframework.cloud.alibaba.sentinel.endpoint;
|
package org.springframework.cloud.alibaba.sentinel.endpoint;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
import org.springframework.boot.actuate.condition.ConditionalOnEnabledEndpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
import org.springframework.boot.actuate.endpoint.Endpoint;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
@ -33,7 +33,7 @@ public class SentinelEndpointAutoConfiguration {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
@ConditionalOnEnabledEndpoint
|
@ConditionalOnEnabledEndpoint("sentinel")
|
||||||
public SentinelEndpoint sentinelEndPoint() {
|
public SentinelEndpoint sentinelEndPoint() {
|
||||||
return new SentinelEndpoint();
|
return new SentinelEndpoint();
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,14 @@
|
|||||||
|
|
||||||
package org.springframework.cloud.alibaba.sentinel;
|
package org.springframework.cloud.alibaba.sentinel;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
import org.springframework.cloud.alibaba.sentinel.custom.SentinelAspect;
|
import org.springframework.cloud.alibaba.sentinel.custom.SentinelAspect;
|
||||||
import org.springframework.cloud.alibaba.sentinel.custom.SentinelCustomAspectAutoConfiguration;
|
import org.springframework.cloud.alibaba.sentinel.custom.SentinelCustomAspectAutoConfiguration;
|
||||||
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -31,35 +33,42 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*/
|
*/
|
||||||
public class SentinelAutoConfigurationTests {
|
public class SentinelAutoConfigurationTests {
|
||||||
|
|
||||||
private WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
|
private final AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
|
||||||
.withConfiguration(
|
|
||||||
AutoConfigurations.of(SentinelCustomAspectAutoConfiguration.class, SentinelWebAutoConfiguration.class))
|
@Before
|
||||||
.withPropertyValues("spring.cloud.sentinel.port=8888")
|
public void init() {
|
||||||
.withPropertyValues("spring.cloud.sentinel.filter.order=123")
|
context.register(SentinelCustomAspectAutoConfiguration.class, SentinelWebAutoConfiguration.class);
|
||||||
.withPropertyValues("spring.cloud.sentinel.filter.urlPatterns=/*,/test");
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
|
"spring.cloud.sentinel.port=8888",
|
||||||
|
"spring.cloud.sentinel.filter.order=123",
|
||||||
|
"spring.cloud.sentinel.filter.urlPatterns=/*,/test");
|
||||||
|
this.context.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void closeContext() {
|
||||||
|
this.context.close();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSentinelAspect() {
|
public void testSentinelAspect() {
|
||||||
this.contextRunner.run(context -> assertThat(context).hasSingleBean(SentinelAspect.class));
|
assertThat(context.getBean(SentinelAspect.class)).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFilter() {
|
public void testFilter() {
|
||||||
this.contextRunner.run(context -> {
|
|
||||||
assertThat(context.getBean(
|
assertThat(context.getBean(
|
||||||
"servletRequestListener").getClass() == FilterRegistrationBean.class).isTrue();
|
"servletRequestListener").getClass() == FilterRegistrationBean.class).isTrue();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testProperties() {
|
public void testProperties() {
|
||||||
this.contextRunner.run(context -> {
|
|
||||||
SentinelProperties sentinelProperties = context.getBean(SentinelProperties.class);
|
SentinelProperties sentinelProperties = context.getBean(SentinelProperties.class);
|
||||||
|
assertThat(sentinelProperties).isNotNull();
|
||||||
assertThat(sentinelProperties.getPort()).isEqualTo("8888");
|
assertThat(sentinelProperties.getPort()).isEqualTo("8888");
|
||||||
assertThat(sentinelProperties.getFilter().getUrlPatterns().size()).isEqualTo(2);
|
assertThat(sentinelProperties.getFilter().getUrlPatterns().size()).isEqualTo(2);
|
||||||
assertThat(sentinelProperties.getFilter().getUrlPatterns().get(0)).isEqualTo("/*");
|
assertThat(sentinelProperties.getFilter().getUrlPatterns().get(0)).isEqualTo("/*");
|
||||||
assertThat(sentinelProperties.getFilter().getUrlPatterns().get(1)).isEqualTo("/test");
|
assertThat(sentinelProperties.getFilter().getUrlPatterns().get(1)).isEqualTo("/test");
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba</artifactId>
|
<artifactId>spring-cloud-alibaba</artifactId>
|
||||||
<version>0.2.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0.BUILD-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>spring-cloud-starter-sentinel</artifactId>
|
<artifactId>spring-cloud-starter-sentinel</artifactId>
|
||||||
<name>Spring Cloud Starter Sentinel</name>
|
<name>Spring Cloud Starter Sentinel</name>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user