mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
optimize dubbo dependency and code style
This commit is contained in:
parent
54d97a37b4
commit
a27d0e2c71
12
pom.xml
12
pom.xml
@ -81,14 +81,16 @@
|
||||
<spring-cloud-stream.version>Horsham.RELEASE</spring-cloud-stream.version>
|
||||
<spring-cloud-consul.version>2.2.0.RELEASE</spring-cloud-consul.version>
|
||||
<spring-cloud-config.version>2.2.0.RELEASE</spring-cloud-config.version>
|
||||
<spring-cloud-zookeeper.version>2.2.0.RELEASE</spring-cloud-zookeeper.version>
|
||||
|
||||
<junit.version>4.12</junit.version>
|
||||
<javax-servlet-api>3.0</javax-servlet-api>
|
||||
<slf4j-api.version>1.7.25</slf4j-api.version>
|
||||
|
||||
<!-- Apache Dubbo -->
|
||||
<dubbo-spring-boot.version>2.7.1</dubbo-spring-boot.version>
|
||||
<dubbo-spring-boot.version>2.7.3</dubbo-spring-boot.version>
|
||||
<dubbo.version>2.7.3</dubbo.version>
|
||||
<curator.version>4.0.1</curator.version>
|
||||
|
||||
<!-- Apache RocketMQ -->
|
||||
<rocketmq.starter.version>2.0.2</rocketmq.starter.version>
|
||||
@ -218,6 +220,14 @@
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-zookeeper-dependencies</artifactId>
|
||||
<version>${spring-cloud-zookeeper.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-starter</artifactId>
|
||||
|
@ -29,7 +29,6 @@
|
||||
<alicloud.context.version>1.0.5</alicloud.context.version>
|
||||
<aliyun.sdk.edas.version>2.44.0</aliyun.sdk.edas.version>
|
||||
<schedulerX.client.version>2.1.6</schedulerX.client.version>
|
||||
<dubbo.version>2.7.3</dubbo.version>
|
||||
<aliyun.java.sdk.dysmsapi>1.1.0</aliyun.java.sdk.dysmsapi>
|
||||
<aliyun.sdk.mns>1.1.8.6</aliyun.sdk.mns>
|
||||
<aliyun.java.sdk.dyvmsapi>1.1.1</aliyun.java.sdk.dyvmsapi>
|
||||
|
@ -13,12 +13,6 @@
|
||||
<artifactId>spring-cloud-alibaba-dubbo</artifactId>
|
||||
<name>Spring Cloud Alibaba Dubbo</name>
|
||||
|
||||
<properties>
|
||||
<spring-cloud-zookeeper.version>2.2.0.RELEASE</spring-cloud-zookeeper.version>
|
||||
<spring-cloud-consul.version>2.2.0.RELEASE</spring-cloud-consul.version>
|
||||
<curator.version>4.0.1</curator.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
|
@ -3,10 +3,10 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-build</artifactId>
|
||||
<version>2.2.0.RELEASE</version>
|
||||
<relativePath/>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
||||
<version>2.2.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -26,79 +26,4 @@
|
||||
<module>spring-cloud-dubbo-servlet-gateway-sample</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<dubbo.version>2.7.3</dubbo.version>
|
||||
<spring-cloud-commons.version>2.2.0.RELEASE</spring-cloud-commons.version>
|
||||
<spring-cloud-netflix.version>2.2.0.RELEASE</spring-cloud-netflix.version>
|
||||
<spring-cloud-openfeign.version>2.2.0.RELEASE</spring-cloud-openfeign.version>
|
||||
<spring-cloud-zookeeper.version>2.2.0.RELEASE</spring-cloud-zookeeper.version>
|
||||
<spring-cloud-consul.version>2.2.0.RELEASE</spring-cloud-consul.version>
|
||||
<curator.version>4.0.1</curator.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- Spring Boot dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Cloud Alibaba dependencies -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix-dependencies</artifactId>
|
||||
<version>${spring-cloud-netflix.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-openfeign-dependencies</artifactId>
|
||||
<version>${spring-cloud-openfeign.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-bom</artifactId>
|
||||
<version>${dubbo.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -3,10 +3,10 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-build</artifactId>
|
||||
<version>2.1.3.RELEASE</version>
|
||||
<relativePath/>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dubbo-examples</artifactId>
|
||||
<version>2.2.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -15,19 +15,6 @@
|
||||
<name>Spring Cloud Dubbo Client Sample</name>
|
||||
<version>2.2.0.BUILD-SNAPSHOT</version>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- Spring Cloud Alibaba dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||
<version>0.9.0.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<!-- Sample API -->
|
||||
<dependency>
|
||||
@ -49,13 +36,13 @@
|
||||
|
||||
<!-- Dubbo Spring Cloud Starter -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-dubbo</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Cloud Nacos Service Discovery -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -17,7 +17,6 @@
|
||||
package com.alibaba.cloud.dubbo.bootstrap;
|
||||
|
||||
import com.alibaba.cloud.dubbo.service.EchoService;
|
||||
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@ -27,7 +26,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Dubbo Spring Cloud Client Bootstrap
|
||||
* Dubbo Spring Cloud Client Bootstrap.
|
||||
*/
|
||||
@EnableDiscoveryClient
|
||||
@EnableAutoConfiguration
|
||||
@ -45,4 +44,5 @@ public class DubboSpringCloudClientBootstrap {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DubboSpringCloudClientBootstrap.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -68,7 +68,6 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
|
||||
<version>${spring-cloud-zookeeper.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.zookeeper</groupId>
|
||||
|
@ -23,7 +23,6 @@ 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.springframework.beans.factory.annotation.Autowired;
|
||||
@ -49,6 +48,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
* Dubbo Spring Cloud Consumer Bootstrap.
|
||||
@ -81,51 +81,6 @@ public class DubboSpringCloudConsumerBootstrap {
|
||||
@LoadBalanced
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@FeignClient("${provider.application.name}")
|
||||
public interface FeignRestService {
|
||||
|
||||
@GetMapping(value = "/param")
|
||||
String param(@RequestParam("param") String param);
|
||||
|
||||
@PostMapping("/params")
|
||||
public String params(@RequestParam("b") String b, @RequestParam("a") int a);
|
||||
|
||||
@PostMapping(value = "/request/body/map", produces = APPLICATION_JSON_UTF8_VALUE)
|
||||
User requestBody(@RequestParam("param") String param,
|
||||
@RequestBody Map<String, Object> data);
|
||||
|
||||
@GetMapping("/headers")
|
||||
public String headers(@RequestHeader("h2") String header2,
|
||||
@RequestHeader("h") String header, @RequestParam("v") Integer value);
|
||||
|
||||
@GetMapping("/path-variables/{p1}/{p2}")
|
||||
public String pathVariables(@PathVariable("p2") String path2,
|
||||
@PathVariable("p1") String path1, @RequestParam("v") String param);
|
||||
}
|
||||
|
||||
@FeignClient("${provider.application.name}")
|
||||
@DubboTransported(protocol = "dubbo")
|
||||
public interface DubboFeignRestService {
|
||||
|
||||
@GetMapping(value = "/param")
|
||||
String param(@RequestParam("param") String param);
|
||||
|
||||
@PostMapping("/params")
|
||||
String params(@RequestParam("b") String paramB, @RequestParam("a") int paramA);
|
||||
|
||||
@PostMapping(value = "/request/body/map", produces = APPLICATION_JSON_UTF8_VALUE)
|
||||
User requestBody(@RequestParam("param") String param,
|
||||
@RequestBody Map<String, Object> data);
|
||||
|
||||
@GetMapping("/headers")
|
||||
public String headers(@RequestHeader("h2") String header2,
|
||||
@RequestParam("v") Integer value, @RequestHeader("h") String header);
|
||||
|
||||
@GetMapping("/path-variables/{p1}/{p2}")
|
||||
public String pathVariables(@RequestParam("v") String param,
|
||||
@PathVariable("p2") String path2, @PathVariable("p1") String path1);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ApplicationRunner userServiceRunner() {
|
||||
return arguments -> {
|
||||
@ -256,4 +211,52 @@ public class DubboSpringCloudConsumerBootstrap {
|
||||
new SpringApplicationBuilder(DubboSpringCloudConsumerBootstrap.class)
|
||||
.properties("spring.profiles.active=nacos").run(args);
|
||||
}
|
||||
|
||||
@FeignClient("${provider.application.name}")
|
||||
public interface FeignRestService {
|
||||
|
||||
@GetMapping("/param")
|
||||
String param(@RequestParam("param") String param);
|
||||
|
||||
@PostMapping("/params")
|
||||
String params(@RequestParam("b") String b, @RequestParam("a") int a);
|
||||
|
||||
@PostMapping(value = "/request/body/map", produces = APPLICATION_JSON_VALUE)
|
||||
User requestBody(@RequestParam("param") String param,
|
||||
@RequestBody Map<String, Object> data);
|
||||
|
||||
@GetMapping("/headers")
|
||||
String headers(@RequestHeader("h2") String header2,
|
||||
@RequestHeader("h") String header, @RequestParam("v") Integer value);
|
||||
|
||||
@GetMapping("/path-variables/{p1}/{p2}")
|
||||
String pathVariables(@PathVariable("p2") String path2,
|
||||
@PathVariable("p1") String path1, @RequestParam("v") String param);
|
||||
|
||||
}
|
||||
|
||||
@FeignClient("${provider.application.name}")
|
||||
@DubboTransported(protocol = "dubbo")
|
||||
public interface DubboFeignRestService {
|
||||
|
||||
@GetMapping("/param")
|
||||
String param(@RequestParam("param") String param);
|
||||
|
||||
@PostMapping("/params")
|
||||
String params(@RequestParam("b") String paramB, @RequestParam("a") int paramA);
|
||||
|
||||
@PostMapping(value = "/request/body/map", produces = APPLICATION_JSON_UTF8_VALUE)
|
||||
User requestBody(@RequestParam("param") String param,
|
||||
@RequestBody Map<String, Object> data);
|
||||
|
||||
@GetMapping("/headers")
|
||||
String headers(@RequestHeader("h2") String header2,
|
||||
@RequestParam("v") Integer value, @RequestHeader("h") String header);
|
||||
|
||||
@GetMapping("/path-variables/{p1}/{p2}")
|
||||
String pathVariables(@RequestParam("v") String param,
|
||||
@PathVariable("p2") String path2, @PathVariable("p1") String path1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -59,7 +59,6 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
|
||||
<version>${spring-cloud-zookeeper.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.zookeeper</groupId>
|
||||
@ -137,6 +136,18 @@
|
||||
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-bom</artifactId>
|
||||
<version>${dubbo.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
@ -33,4 +33,5 @@ public class DubboSpringCloudProviderBootstrap {
|
||||
.properties("spring.profiles.active=nacos").web(WebApplicationType.NONE)
|
||||
.run(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,4 +44,5 @@ public class InMemoryUserService implements UserService {
|
||||
public Collection<User> findAll() {
|
||||
return usersRepository.values();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -119,4 +119,5 @@ public class StandardRestService implements RestService {
|
||||
map.put("age", user.getAge());
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,7 +58,6 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
|
||||
<version>${spring-cloud-zookeeper.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.zookeeper</groupId>
|
||||
|
@ -31,4 +31,5 @@ public class DubboSpringCloudWebProviderBootstrap {
|
||||
new SpringApplicationBuilder(DubboSpringCloudWebProviderBootstrap.class)
|
||||
.properties("spring.profiles.active=nacos").run(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,4 +44,5 @@ public class InMemoryUserService implements UserService {
|
||||
public Collection<User> findAll() {
|
||||
return usersRepository.values();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class SpringRestService implements RestService {
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Override
|
||||
@GetMapping(value = "/param")
|
||||
@GetMapping("/param")
|
||||
public String param(@RequestParam String param) {
|
||||
log("/param", param);
|
||||
return param;
|
||||
@ -84,7 +84,8 @@ public class SpringRestService implements RestService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(value = "/request/body/map", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
@PostMapping(value = "/request/body/map",
|
||||
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
public User requestBodyMap(@RequestBody Map<String, Object> data,
|
||||
@RequestParam("param") String param) {
|
||||
User user = new User();
|
||||
@ -95,7 +96,8 @@ public class SpringRestService implements RestService {
|
||||
return user;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/request/body/user", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
@PostMapping(value = "/request/body/user",
|
||||
consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
@Override
|
||||
public Map<String, Object> requestBodyUser(@RequestBody User user) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
@ -22,4 +22,5 @@ package com.alibaba.cloud.dubbo.service;
|
||||
public interface EchoService {
|
||||
|
||||
String echo(String message);
|
||||
|
||||
}
|
||||
|
@ -38,4 +38,5 @@ public interface RestService {
|
||||
User requestBodyMap(Map<String, Object> data, String param);
|
||||
|
||||
Map<String, Object> requestBodyUser(User user);
|
||||
|
||||
}
|
||||
|
@ -59,4 +59,5 @@ public class User implements Serializable {
|
||||
public String toString() {
|
||||
return "User{" + "id=" + id + ", name='" + name + '\'' + ", age=" + age + '}';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,4 +30,5 @@ public interface UserService {
|
||||
boolean remove(Long userId);
|
||||
|
||||
Collection<User> findAll();
|
||||
|
||||
}
|
||||
|
@ -38,4 +38,5 @@ public abstract class LoggerUtils {
|
||||
logger.info(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,10 +3,10 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-build</artifactId>
|
||||
<version>2.1.3.RELEASE</version>
|
||||
<relativePath/>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dubbo-examples</artifactId>
|
||||
<version>2.2.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@ -16,19 +16,6 @@
|
||||
<name>Spring Cloud Dubbo Server Sample</name>
|
||||
<version>2.2.0.BUILD-SNAPSHOT</version>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- Spring Cloud Alibaba dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||
<version>0.9.0.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Sample API -->
|
||||
@ -46,13 +33,13 @@
|
||||
|
||||
<!-- Dubbo Spring Cloud Starter -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-dubbo</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Cloud Nacos Service Discovery -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -17,7 +17,6 @@
|
||||
package com.alibaba.cloud.dubbo.bootstrap;
|
||||
|
||||
import com.alibaba.cloud.dubbo.service.EchoService;
|
||||
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@ -34,6 +33,7 @@ public class DubboSpringCloudServerBootstrap {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DubboSpringCloudServerBootstrap.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Service
|
||||
@ -43,4 +43,5 @@ class EchoServiceImpl implements EchoService {
|
||||
public String echo(String message) {
|
||||
return "[echo] Hello, " + message;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,4 +35,5 @@ public class DubboSpringCloudServletGatewayBootstrap {
|
||||
new SpringApplicationBuilder(DubboSpringCloudServletGatewayBootstrap.class)
|
||||
.properties("spring.profiles.active=nacos").run(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ import com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepositor
|
||||
import com.alibaba.cloud.dubbo.service.DubboGenericServiceExecutionContext;
|
||||
import com.alibaba.cloud.dubbo.service.DubboGenericServiceExecutionContextFactory;
|
||||
import com.alibaba.cloud.dubbo.service.DubboGenericServiceFactory;
|
||||
|
||||
import org.apache.dubbo.rpc.service.GenericException;
|
||||
import org.apache.dubbo.rpc.service.GenericService;
|
||||
|
||||
@ -148,37 +147,6 @@ public class DubboGatewayServlet extends HttpServletBean {
|
||||
return StreamUtils.copyToByteArray(inputStream);
|
||||
}
|
||||
|
||||
private static class HttpRequestAdapter implements HttpRequest {
|
||||
|
||||
private final HttpServletRequest request;
|
||||
|
||||
private HttpRequestAdapter(HttpServletRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodValue() {
|
||||
return request.getMethod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getURI() {
|
||||
try {
|
||||
return new URI(request.getRequestURL().toString() + "?"
|
||||
+ request.getQueryString());
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
return new HttpHeaders();
|
||||
}
|
||||
}
|
||||
|
||||
private RequestMetadata buildRequestMetadata(HttpServletRequest request,
|
||||
String restPath) {
|
||||
UriComponents uriComponents = fromUriString(request.getRequestURI()).build(true);
|
||||
@ -208,4 +176,37 @@ public class DubboGatewayServlet extends HttpServletBean {
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private final static class HttpRequestAdapter implements HttpRequest {
|
||||
|
||||
private final HttpServletRequest request;
|
||||
|
||||
private HttpRequestAdapter(HttpServletRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodValue() {
|
||||
return request.getMethod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getURI() {
|
||||
try {
|
||||
return new URI(request.getRequestURL().toString() + "?"
|
||||
+ request.getQueryString());
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
return new HttpHeaders();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user