diff --git a/im-entry/pom.xml b/im-entry/pom.xml index 8f94ca9..c98597f 100644 --- a/im-entry/pom.xml +++ b/im-entry/pom.xml @@ -38,11 +38,15 @@ org.apache.dubbo dubbo-spring-boot-starter + + org.apache.dubbo + dubbo-registry-zookeeper + - + diff --git a/im-entry/src/main/java/net/sopod/soim/entry/EntryApplication.java b/im-entry/src/main/java/net/sopod/soim/entry/EntryApplication.java index a69eec5..d5686bc 100644 --- a/im-entry/src/main/java/net/sopod/soim/entry/EntryApplication.java +++ b/im-entry/src/main/java/net/sopod/soim/entry/EntryApplication.java @@ -1,5 +1,6 @@ package net.sopod.soim.entry; +import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; @@ -12,6 +13,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; * @date 2022-03-26 00:06 */ @SpringBootApplication +@EnableDubbo(scanBasePackages = {"net.sopod.soim.entry.service"}) public class EntryApplication { private static final Logger logger = LoggerFactory.getLogger(EntryApplication.class); diff --git a/im-entry/src/main/java/net/sopod/soim/entry/service/HelloService.java b/im-entry/src/main/java/net/sopod/soim/entry/service/HelloService.java new file mode 100644 index 0000000..ceccd7c --- /dev/null +++ b/im-entry/src/main/java/net/sopod/soim/entry/service/HelloService.java @@ -0,0 +1,7 @@ +package net.sopod.soim.entry.service; + +public interface HelloService { + + String sayHello(String name); + +} diff --git a/im-entry/src/main/java/net/sopod/soim/entry/service/HelloServiceImpl.java b/im-entry/src/main/java/net/sopod/soim/entry/service/HelloServiceImpl.java new file mode 100644 index 0000000..85e8799 --- /dev/null +++ b/im-entry/src/main/java/net/sopod/soim/entry/service/HelloServiceImpl.java @@ -0,0 +1,21 @@ +package net.sopod.soim.entry.service; + +import org.apache.dubbo.config.annotation.DubboService; +import org.apache.dubbo.rpc.RpcContext; + +/** + * HelloServiceImpl + * + * @author tmy + * @date 2022-03-28 16:23 + */ +@DubboService(version = "1.0.0") +public class HelloServiceImpl implements HelloService { + + @Override + public String sayHello(String name) { + System.out.println("be invoked! client:" + RpcContext.getClientAttachment().getObjectAttachments()); + return "hello "+ name; + } + +} diff --git a/im-entry/src/main/resources/application.yml b/im-entry/src/main/resources/application.yml index 5b4e60c..a3c6b77 100644 --- a/im-entry/src/main/resources/application.yml +++ b/im-entry/src/main/resources/application.yml @@ -1,4 +1,10 @@ +spring: + application: + name: im-entry dubbo: - enabled: false application: - name: im-entry \ No newline at end of file + name: ${spring.application.name} + #enabled: true + registry: + address: zookeeper://124.222.131.236:2181?timeout=10000 + client: zkclient \ No newline at end of file diff --git a/pom.xml b/pom.xml index eafdb7b..a34b861 100644 --- a/pom.xml +++ b/pom.xml @@ -33,6 +33,7 @@ 4.1.72.Final 2.1.8.RELEASE 3.0.5 + 4.2.0 @@ -121,14 +122,37 @@ org.springframework.boot spring-boot-starter ${spring-boot.version} - - org.apache.dubbo dubbo-spring-boot-starter ${dubbo.version} + + org.apache.dubbo + dubbo-registry-zookeeper + ${dubbo.version} + + + org.apache.curator + curator-framework + 4.2.0 + + + org.apache.curator + curator-recipes + 4.2.0 + + @@ -158,7 +182,7 @@ - +