diff --git a/im-entry/pom.xml b/im-entry/pom.xml index e5f4fb7..4aa04b4 100644 --- a/im-entry/pom.xml +++ b/im-entry/pom.xml @@ -58,11 +58,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 bfa0f6d..63b73af 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,7 +1,6 @@ package net.sopod.soim.entry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -12,15 +11,10 @@ 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); - public static void main(String[] args) { - logger.info("二狗腿子:{}", 1); - logger.info("二狗腿子:{}", 2); - logger.info("二狗腿子:{}", 3); - System.out.println("狗腿子4"); SpringApplication.run(EntryApplication.class, args); } 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 a4c1ac2..56bbc52 100644 --- a/im-entry/src/main/resources/application.yml +++ b/im-entry/src/main/resources/application.yml @@ -1,4 +1,10 @@ -dubbo: - enabled: false +spring: application: name: im-entry +dubbo: + application: + name: ${spring.application.name} + #enabled: true + registry: + address: zookeeper://124.222.131.236:3181?timeout=10000 + client: zkclient \ No newline at end of file diff --git a/pom.xml b/pom.xml index 92e15c4..99fabae 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 @@ -78,12 +79,6 @@ 3.4 - - com.zaxxer - HikariCP - 3.4.5 - - org.slf4j @@ -127,7 +122,37 @@ 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 + + + + com.zaxxer + HikariCP + 3.4.5 + mysql mysql-connector-java @@ -162,7 +187,7 @@ - +