mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
merge from 2.2.4.RELEASE
This commit is contained in:
@@ -13,14 +13,13 @@
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-dubbo-client-sample</artifactId>
|
||||
<name>Spring Cloud Dubbo Client Sample</name>
|
||||
<version>${revision}</version>
|
||||
|
||||
<dependencies>
|
||||
<!-- Sample API -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-dubbo-sample-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot dependencies -->
|
||||
|
@@ -17,7 +17,7 @@
|
||||
package com.alibaba.cloud.dubbo.bootstrap;
|
||||
|
||||
import com.alibaba.cloud.dubbo.service.EchoService;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -27,13 +27,15 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Dubbo Spring Cloud Client Bootstrap.
|
||||
*
|
||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||
*/
|
||||
@EnableDiscoveryClient
|
||||
@EnableAutoConfiguration
|
||||
@RestController
|
||||
public class DubboSpringCloudClientBootstrap {
|
||||
|
||||
@Reference
|
||||
@DubboReference
|
||||
private EchoService echoService;
|
||||
|
||||
@GetMapping("/echo")
|
||||
|
@@ -1,6 +1,9 @@
|
||||
dubbo:
|
||||
cloud:
|
||||
subscribed-services: spring-cloud-alibaba-dubbo-server
|
||||
protocols:
|
||||
dubbo:
|
||||
port: -1
|
||||
|
||||
spring:
|
||||
application:
|
||||
|
@@ -23,7 +23,7 @@ import com.alibaba.cloud.dubbo.annotation.DubboTransported;
|
||||
import com.alibaba.cloud.dubbo.service.RestService;
|
||||
import com.alibaba.cloud.dubbo.service.User;
|
||||
import com.alibaba.cloud.dubbo.service.UserService;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -52,6 +52,8 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
* Dubbo Spring Cloud Consumer Bootstrap.
|
||||
*
|
||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||
*/
|
||||
@EnableDiscoveryClient
|
||||
@EnableAutoConfiguration
|
||||
@@ -60,10 +62,10 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
@EnableCaching
|
||||
public class DubboSpringCloudConsumerBootstrap {
|
||||
|
||||
@Reference
|
||||
@DubboReference
|
||||
private UserService userService;
|
||||
|
||||
@Reference(version = "1.0.0", protocol = "dubbo")
|
||||
@DubboReference(version = "1.0.0", protocol = "dubbo")
|
||||
private RestService restService;
|
||||
|
||||
@Autowired
|
||||
|
@@ -1,14 +1,12 @@
|
||||
dubbo:
|
||||
registry:
|
||||
# The Spring Cloud Dubbo's registry extension
|
||||
## the default value of dubbo-provider-services is "*", that means to subscribe all providers,
|
||||
## thus it's optimized if subscriber specifies the required providers.
|
||||
address: spring-cloud://localhost
|
||||
# The traditional Dubbo's registry also is supported
|
||||
# address: zookeeper://127.0.0.1:2181
|
||||
cloud:
|
||||
# The subscribed services in consumer side
|
||||
subscribed-services: ${provider.application.name}
|
||||
protocols:
|
||||
dubbo:
|
||||
port: -1
|
||||
consumer:
|
||||
check: false
|
||||
|
||||
consumer:
|
||||
check: false
|
||||
|
@@ -8,6 +8,8 @@ spring:
|
||||
# default disable all
|
||||
cloud:
|
||||
nacos:
|
||||
username: nacos
|
||||
password: nacos
|
||||
discovery:
|
||||
enabled: false
|
||||
register-enabled: false
|
||||
|
@@ -23,6 +23,8 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* Dubbo Spring Cloud Provider Bootstrap.
|
||||
*
|
||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||
*/
|
||||
@EnableDiscoveryClient
|
||||
@EnableAutoConfiguration
|
||||
|
@@ -20,12 +20,12 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
/**
|
||||
* In-Memory {@link UserService} implementation.
|
||||
*/
|
||||
@Service(protocol = "dubbo")
|
||||
@DubboService(protocol = "dubbo")
|
||||
public class InMemoryUserService implements UserService {
|
||||
|
||||
private Map<Long, User> usersRepository = new HashMap<>();
|
||||
|
@@ -30,7 +30,7 @@ import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -42,7 +42,7 @@ import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON_VALUE;
|
||||
*
|
||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||
*/
|
||||
@Service(version = "1.0.0", protocol = { "dubbo", "rest" })
|
||||
@DubboService(version = "1.0.0", protocol = { "dubbo", "rest" })
|
||||
@Path("/")
|
||||
public class StandardRestService implements RestService {
|
||||
|
||||
|
@@ -9,11 +9,6 @@ dubbo:
|
||||
name: rest
|
||||
port: 9090
|
||||
server: netty
|
||||
registry:
|
||||
# The Spring Cloud Dubbo's registry extension
|
||||
address: spring-cloud://localhost
|
||||
# The traditional Dubbo's registry
|
||||
# address: zookeeper://127.0.0.1:2181
|
||||
feign:
|
||||
hystrix:
|
||||
enabled: true
|
@@ -33,6 +33,7 @@ spring:
|
||||
enabled: true
|
||||
register-enabled: true
|
||||
server-addr: 127.0.0.1:8848
|
||||
ephemeral: false
|
||||
|
||||
|
||||
---
|
||||
|
@@ -22,6 +22,8 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* Dubbo Spring Cloud Provider Bootstrap.
|
||||
*
|
||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||
*/
|
||||
@EnableDiscoveryClient
|
||||
@EnableAutoConfiguration
|
||||
|
@@ -20,12 +20,12 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
/**
|
||||
* In-Memory {@link UserService} implementation.
|
||||
*/
|
||||
@Service(protocol = "dubbo")
|
||||
@DubboService(protocol = "dubbo")
|
||||
public class InMemoryUserService implements UserService {
|
||||
|
||||
private Map<Long, User> usersRepository = new HashMap<>();
|
||||
|
@@ -19,7 +19,7 @@ package com.alibaba.cloud.dubbo.service;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -39,7 +39,7 @@ import static com.alibaba.cloud.dubbo.util.LoggerUtils.log;
|
||||
*
|
||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||
*/
|
||||
@Service(version = "1.0.0")
|
||||
@DubboService(version = "1.0.0")
|
||||
@RestController
|
||||
public class SpringRestService implements RestService {
|
||||
|
||||
|
@@ -3,16 +3,7 @@ dubbo:
|
||||
base-packages: com.alibaba.cloud.dubbo.service
|
||||
protocols:
|
||||
dubbo:
|
||||
name: dubbo
|
||||
port: -1
|
||||
registries:
|
||||
new:
|
||||
address: spring-cloud://localhost
|
||||
# registry:
|
||||
# The Spring Cloud Dubbo's registry extension
|
||||
# address: spring-cloud://localhost
|
||||
# The traditional Dubbo's registry
|
||||
# address: nacos://127.0.0.1:8848
|
||||
|
||||
feign:
|
||||
hystrix:
|
||||
|
@@ -8,6 +8,8 @@ spring:
|
||||
# default disable all
|
||||
cloud:
|
||||
nacos:
|
||||
username: nacos
|
||||
password: nacos
|
||||
discovery:
|
||||
enabled: false
|
||||
register-enabled: false
|
||||
|
@@ -17,7 +17,7 @@
|
||||
package com.alibaba.cloud.dubbo.bootstrap;
|
||||
|
||||
import com.alibaba.cloud.dubbo.service.EchoService;
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -25,6 +25,8 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* Dubbo Spring Cloud Server Bootstrap.
|
||||
*
|
||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||
*/
|
||||
@EnableDiscoveryClient
|
||||
@EnableAutoConfiguration
|
||||
@@ -36,7 +38,7 @@ public class DubboSpringCloudServerBootstrap {
|
||||
|
||||
}
|
||||
|
||||
@Service
|
||||
@DubboService
|
||||
class EchoServiceImpl implements EchoService {
|
||||
|
||||
@Override
|
||||
|
@@ -24,6 +24,8 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* Dubbo Spring Cloud Servlet Gateway Bootstrap.
|
||||
*
|
||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||
*/
|
||||
@EnableDiscoveryClient
|
||||
@EnableAutoConfiguration
|
||||
|
@@ -52,8 +52,8 @@ import org.springframework.util.StreamUtils;
|
||||
import org.springframework.web.servlet.HttpServletBean;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.substringAfter;
|
||||
import static org.apache.commons.lang3.StringUtils.substringBetween;
|
||||
import static org.apache.commons.lang.StringUtils.substringAfter;
|
||||
import static org.apache.commons.lang.StringUtils.substringBetween;
|
||||
import static org.springframework.web.util.UriComponentsBuilder.fromUriString;
|
||||
|
||||
@WebServlet(urlPatterns = "/dsc/*")
|
||||
|
Reference in New Issue
Block a user