Update README.md
1 file changed
tree: d6296ad4029905be043248b8e0a17a19b06435fb
  1. .mvn/
  2. dubbo-spring-boot-actuator/
  3. dubbo-spring-boot-autoconfigure/
  4. dubbo-spring-boot-distribution/
  5. dubbo-spring-boot-parent/
  6. dubbo-spring-boot-samples/
  7. dubbo-spring-boot-starter/
  8. .gitignore
  9. .travis.yml
  10. config-popup-window.png
  11. DISCLAIMER
  12. LICENSE
  13. mconfig-popup-window.png
  14. mvnw
  15. mvnw.cmd
  16. NOTICE
  17. pom.xml
  18. README.md
  19. README_CN.md
README.md

Dubbo Spring Boot Project

Dubbo Spring Boot Project makes it easy to create Spring Boot application using Dubbo as RPC Framework. What's more, it aslo provides

Dubbo |ˈdʌbəʊ| is a high-performance, java based RPC framework open-sourced by Alibaba. As in many RPC systems, dubbo is based around the idea of defining a service, specifying the methods that can be called remotely with their parameters and return types. On the server side, the server implements this interface and runs a dubbo server to handle client calls. On the client side, the client has a stub that provides the same methods as the server.

Current Project is a legacy one for maintaining Spring Boot 1.x

中文说明

Released Version

You can introduce the latest dubbo-spring-boot-starter to your project by adding the following dependency to your pom.xml

<properties>
    <spring-boot.version>1.5.18.RELEASE</spring-boot.version>
    <dubbo.version>2.6.5</dubbo.version>
</properties>

<dependencyManagement>
    <dependencies>
        <!-- Spring Boot -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>${spring-boot.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    
        <!-- Dubbo dependencies -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo-dependencies-bom</artifactId>
            <version>${dubbo.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <!-- Dubbo Spring Boot Starter -->
    <dependency>
        <groupId>com.alibaba.boot</groupId>
        <artifactId>dubbo-spring-boot-autoconfigure</artifactId>
        <version>0.1.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>dubbo</artifactId>
        <version>${dubbo.version}</version>
    </dependency>
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-all</artifactId>
    </dependency>
</dependencies>

If your project failed to resolve the dependency, try to add the following repository:

<repositories>
    <repository>
        <id>sonatype-nexus-snapshots</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

Developing Version

Build from Source

If you'd like to attempt to experience latest features, you also can build from source as follow:

  1. Maven install current project in your local repository.

Maven install = mvn install

Dependencies

versionsJavaSpring BootDubbo
0.1.x1.7+1.5.x2.6.x +

Getting Started

If you don't know about Dubbo , please take a few minutes to learn http://dubbo.io/ . After that you could dive deep into dubbo user guide.

Usually , There are two usage scenarios for Dubbo applications , one is Dubbo service(s) provider , another is Dubbo service(s) consumer, thus let's get a quick start on them.

First of all , we suppose an interface as Dubbo RPC API that a service provider exports and a service client consumes :

public interface DemoService {

    String sayHello(String name);

}

Dubbo service(s) provider

Service Provider implements DemoService :

@Service(
        version = "${demo.service.version}",
        application = "${dubbo.application.id}",
        protocol = "${dubbo.protocol.id}",
        registry = "${dubbo.registry.id}"
)
public class DefaultDemoService implements DemoService {

    public String sayHello(String name) {
        return "Hello, " + name + " (from Spring Boot)";
    }

}

then , provides a bootstrap class :

@SpringBootApplication
public class DubboProviderDemo {

    public static void main(String[] args) {

        SpringApplication.run(DubboProviderDemo.class,args);

    }

}

last , configures application.properties :

# Spring boot application
spring.application.name = dubbo-provider-demo
server.port = 9090
management.port = 9091

# Service version
demo.service.version = 1.0.0

# Base packages to scan Dubbo Components (e.g @Service , @Reference)
dubbo.scan.base-packages  = com.alibaba.boot.dubbo.demo.provider.service

# Dubbo Config properties
## ApplicationConfig Bean
dubbo.application.id = dubbo-provider-demo
dubbo.application.name = dubbo-provider-demo

## ProtocolConfig Bean
dubbo.protocol.id = dubbo
dubbo.protocol.name = dubbo
dubbo.protocol.port = 12345

## RegistryConfig Bean
dubbo.registry.id = my-registry
dubbo.registry.address = N/A

DefaultDemoService's placeholders( ${dubbo.application.id}, ${dubbo.protocol.id}, ${dubbo.registry.id} ) sources from application.properties.

More details , please refer to Dubbo Provider Sample.

Dubbo service(s) consumer

Service consumer requires Spring Beans to reference DemoService :

@RestController
public class DemoConsumerController {

    @Reference(version = "${demo.service.version}",
            application = "${dubbo.application.id}",
            url = "dubbo://localhost:12345")
    private DemoService demoService;

    @RequestMapping("/sayHello")
    public String sayHello(@RequestParam String name) {
        return demoService.sayHello(name);
    }

}

then , also provide a bootstrap class :

@SpringBootApplication(scanBasePackages = "com.alibaba.boot.dubbo.demo.consumer.controller")
public class DubboConsumerDemo {

    public static void main(String[] args) {

        SpringApplication.run(DubboConsumerDemo.class,args);

    }

}

last , configures application.properties :

# Spring boot application
spring.application.name = dubbo-consumer-demo
server.port = 8080
management.port = 8081

# Service version
demo.service.version = 1.0.0

# Dubbo Config properties
## ApplicationConfig Bean
dubbo.application.id = dubbo-consumer-demo
dubbo.application.name = dubbo-consumer-demo

## ProtocolConfig Bean
dubbo.protocol.id = dubbo
dubbo.protocol.name = dubbo
dubbo.protocol.port = 12345

If DubboProviderDemo works well , please mark sure Dubbo service(s) is active.

More details , please refer to Dubbo Consumer Sample

Getting help

Having trouble with Dubbo Spring Boot? We’d like to help!

Building from Source

If you want to try out thr latest features of Dubbo Spring Boot , it can be easily built with the maven wrapper. Your JDK is 1.7 or above.

$ ./mvnw clean install

Modules

There are some modules in Dubbo Spring Boot Project , let's take a look at below overview :

dubbo-spring-boot-parent

The main usage of dubbo-spring-boot-parent is providing dependencies management for other modules.

dubbo-spring-boot-autoconfigure

dubbo-spring-boot-autoconfigure uses Spring Boot‘s @EnableAutoConfiguration which helps core Dubbo’s components to be auto-configured by DubboAutoConfiguration. It reduces code, eliminates XML configuration.

dubbo-spring-boot-actuator

dubbo-spring-boot-actuator provides production-ready features (e.g. health checks, endpoints, and externalized configuration).

dubbo-spring-boot-starter

dubbo-spring-boot-starter is a standard Spring Boot Starter, which contains dubbo-spring-boot-autoconfigure and dubbo-spring-boot-actuator. It will be imported into your application directly.

dubbo-spring-boot-samples

The samples project of Dubbo Spring Boot that includes two parts:

Dubbo Provider Sample

Dubbo Service will be exported on localhost with port 12345.

Dubbo Consumer Sample

Dubbo Service will be consumed at Spring WebMVC Controller .