[color=red]server:[/color]
=======================================================
pom.xml
=============================================
<!-- Spring Boot Dubbo 依赖 -->
<dependency>
<groupId>io.dubbo.springboot</groupId>
<artifactId>spring-boot-starter-dubbo</artifactId>
<version>${dubbo-spring-boot}</version>
</dependency>
=============================================
application.properties
=============================================
spring.dubbo.application.name=provider
spring.dubbo.registry.address=172.16.30.57:2181,172.16.30.57:2182,172.16.30.57:2183
spring.dubbo.protocol.name=dubbo
spring.dubbo.protocol.port=20880
[color=red]spring.dubbo.scan=org.spring.springboot.dubbo[/color]
spring.dubbo.registry.protocol=zookeeper
=============================================
public interface TestDubboService {
String test(String str);
}
=============================================
import com.alibaba.dubbo.config.annotation.Service;
@Service(version = "1.0.0")
public class TestDubboServiceImpl implements TestDubboService {
public String test(String str) {
return "result:"+str;
}
}
=======================================================
[color=red]client:[/color]
=======================================================
pom.xml
=============================================
<!-- Spring Boot Dubbo 依赖 -->
<dependency>
<groupId>io.dubbo.springboot</groupId>
<artifactId>spring-boot-starter-dubbo</artifactId>
<version>${dubbo-spring-boot}</version>
</dependency>
=============================================
application.properties
=============================================
spring.dubbo.application.name=consumer
spring.dubbo.registry.address=172.16.30.57:2181,172.16.30.57:2182,172.16.30.57:2183
[color=red]spring.dubbo.scan=org.spring.springboot.dubbo[/color]
spring.dubbo.registry.protocol=zookeeper
=============================================
public interface TestDubboService {
String test(String str);
}
=============================================
import com.alibaba.dubbo.config.annotation.Reference;
@Component
public class ConsumerService {
@Reference(version = "1.0.0")
TestDubboService testDubboService;
public void testConsumer() {
String result = testDubboService.test("hello world");
System.out.println(result);
}
}
=============================================
=======================================================
pom.xml
=============================================
<!-- Spring Boot Dubbo 依赖 -->
<dependency>
<groupId>io.dubbo.springboot</groupId>
<artifactId>spring-boot-starter-dubbo</artifactId>
<version>${dubbo-spring-boot}</version>
</dependency>
=============================================
application.properties
=============================================
spring.dubbo.application.name=provider
spring.dubbo.registry.address=172.16.30.57:2181,172.16.30.57:2182,172.16.30.57:2183
spring.dubbo.protocol.name=dubbo
spring.dubbo.protocol.port=20880
[color=red]spring.dubbo.scan=org.spring.springboot.dubbo[/color]
spring.dubbo.registry.protocol=zookeeper
=============================================
public interface TestDubboService {
String test(String str);
}
=============================================
import com.alibaba.dubbo.config.annotation.Service;
@Service(version = "1.0.0")
public class TestDubboServiceImpl implements TestDubboService {
public String test(String str) {
return "result:"+str;
}
}
=======================================================
[color=red]client:[/color]
=======================================================
pom.xml
=============================================
<!-- Spring Boot Dubbo 依赖 -->
<dependency>
<groupId>io.dubbo.springboot</groupId>
<artifactId>spring-boot-starter-dubbo</artifactId>
<version>${dubbo-spring-boot}</version>
</dependency>
=============================================
application.properties
=============================================
spring.dubbo.application.name=consumer
spring.dubbo.registry.address=172.16.30.57:2181,172.16.30.57:2182,172.16.30.57:2183
[color=red]spring.dubbo.scan=org.spring.springboot.dubbo[/color]
spring.dubbo.registry.protocol=zookeeper
=============================================
public interface TestDubboService {
String test(String str);
}
=============================================
import com.alibaba.dubbo.config.annotation.Reference;
@Component
public class ConsumerService {
@Reference(version = "1.0.0")
TestDubboService testDubboService;
public void testConsumer() {
String result = testDubboService.test("hello world");
System.out.println(result);
}
}
=============================================