标签:导入 bin 相同 pen font ref frame scan iba
<dependency> <groupId>com.101tec</groupId> <artifactId>zkclient</artifactId> <version>0.10</version> </dependency> <dependency> <groupId>com.alibaba.spring.boot</groupId> <artifactId>dubbo-spring-boot-starter</artifactId> <version>2.0.0</version> </dependency>
spring.dubbo.application.name=prodvice_dubbo01 spring.dubbo.registry.address=zookeeper://127.0.0.1:2181 spring.dubbo.protocol.name=dubbo spring.dubbo.protocol.port=20881 spring.dubbo.scan=com.zk.boot_dubbo01.service server.port=8083
public interface BootService { public String getOne(); }
package com.zk.boot_dubbo01.service; import com.alibaba.dubbo.config.annotation.Service; import org.springframework.stereotype.Component; @Service(interfaceClass = BootService.class) @Component public class BootServiceImpl implements BootService @Override public String getOne() { return "到了---"; } }
package com.zk.boot_dubbo01; import com.alibaba.dubbo.spring.boot.annotation.EnableDubboConfiguration; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication @EnableDubboConfiguration public class BootDubbo01Application { public static void main(String[] args) { SpringApplication.run(BootDubbo01Application.class, args); System.out.println("dfghjkjhe"); } }
<dependency> <groupId>com.101tec</groupId> <artifactId>zkclient</artifactId> <version>0.10</version> </dependency> <dependency> <groupId>com.alibaba.spring.boot</groupId> <artifactId>dubbo-spring-boot-starter</artifactId> <version>2.0.0</version> </dependency>
spring.dubbo.application.name=consumer_dubbo01 spring.dubbo.registry.address=zookeeper://127.0.0.1:2181 spring.dubbo.scan=com.zk.boot_dubbo02.controller server.port=8084
public interface BootService { public String getOne(); }
package com.zk.boot_dubbo01.controller; import com.alibaba.dubbo.config.annotation.Reference; import com.zk.boot_dubbo01.service.BootService; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @RequestMapping("/user") public class UserController { @Reference private BootService service; @RequestMapping("/getOne") @ResponseBody public String getOne(){ String user = service.getOne(); return user; } }
package com.zk.boot_dubbo01; import com.alibaba.dubbo.spring.boot.annotation.EnableDubboConfiguration; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication @EnableDubboConfiguration public class ApplicationStart { public static void main(String[] args) { SpringApplication.run(ApplicationStart.class, args); } }
消费者能调用生产者里面的方法
标签:导入 bin 相同 pen font ref frame scan iba
原文地址:https://www.cnblogs.com/wnwn/p/12039159.html