Skip to content

Commit

Permalink
@DubboService & @DubboReference 服务提供与消费
Browse files Browse the repository at this point in the history
  • Loading branch information
YClimb committed Sep 30, 2020
1 parent 280708b commit 54a6ae1
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;

public class MavenWrapperDownloader {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.demo.controller;

import com.example.demo.EchoService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* Dubbo Spring Cloud 服务消费
*
* @author yclimb
* @date 2020/9/30
*/
@RestController
public class EchoController {

@DubboReference
private EchoService echoService;

@GetMapping("/echo")
public String echo(String message) {
return echoService.echo(message);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
*/
package com.example.demo.nacosdiscovery;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Configuration;

/**
* @author <a href="mailto:[email protected]">theonefx</a>
*/
@EnableDiscoveryClient
@EnableAutoConfiguration
@Configuration
public class NacosDiscoveryConfiguration {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
spring.application.name=dubbo-consumer-sample

# Actuator Web 访问端口
management.server.port=8081
management.server.port=9091
management.endpoints.jmx.exposure.include=*
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always

# 应用服务 WEB 访问端口
server.port=8080
server.port=9090
# spring 静态资源扫描路径
spring.resources.static_locations=classpath:/static/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

/**
* https://start.aliyun.com/article/sca7lesson/rpc
*
* @author yclimb
* @date 2020/9/30
*/
@EnableDiscoveryClient
@SpringBootApplication
public class DubboProviderSampleApplication {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.example.demo.service;

import com.alibaba.cloud.EchoService;
import org.apache.dubbo.config.annotation.Service;
import com.example.demo.EchoService;
import org.apache.dubbo.config.annotation.DubboService;

/**
* Dubbo 服务提供方
*
* @author yclimb
* @date 2020/9/30
*/
@Service
@DubboService
public class SimpleEchoServiceImpl implements EchoService {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alibaba.cloud;
package com.example.demo;

/**
* Dubbo 服务接口
Expand Down

0 comments on commit 54a6ae1

Please sign in to comment.