Giter VIP home page Giter VIP logo

spring-boot-dubbox-demo's Introduction

spring-boot-dubbox-demo

Spring Boot intergrate with Dubbox based on annotation demo

Spring Boot + dubbox全注解方式实例

项目结构说明

  • dubbo-starter 提供类似spring boot starter功能,自动添加dubbox依赖,配置文件自动解析等。
  • api 提供domain model 和 service api
  • order-center 依赖api接口,实现OrderService
  • user-center 依赖api接口,实现UserService

问题及注意事项

  • 如何实现自己的Spring Boot Starter以及如何配置Dubbox?

请参考 dubbo-starter 项目,注意 spring.factories 文件位置及作用。

  • Spring Boot 非web环境如何启动Dubbo服务?
@SpringBootApplication
public class AppMain implements ApplicationRunner {

    public static void main(String[] args) {
        new SpringApplicationBuilder()
                .sources(AppMain.class)
                .web(false) // 这里使用非web环境
                .bannerMode(Banner.Mode.CONSOLE)
                .run(args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        // dubbo 底层netty服务也是异步的,所以需要在ApplicationContext构建后阻塞 
        Thread.currentThread().join();
    }
}
  • Spring Boot + Dubbo + Junit ?
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = AppMain.class,
        webEnvironment = SpringBootTest.WebEnvironment.NONE) // 非Web环境,否则会尝试加载WebContext导致报错
public class TestBase {
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.