zoukankan      html  css  js  c++  java
  • sringboot 集成dobbo2.5.3

    1.sts 创建spring boot 工程,选择web组件

    2.DubboService.java

    package com.example.demo;
    
    public interface DubboService {
    
        public String sayHello();
    }
    View Code

    3.DubboServiceImp.java

    package com.example.demo;
    import org.springframework.stereotype.Service;
    
    @Service("DubboService")
    public class DubboServiceImp implements DubboService{
    
        @Override
        public String sayHello() {
            return "Hello Dubbo";
        }
    }

    3.ZDubboService1Application.java

    package com.example.demo;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.context.annotation.ImportResource;
    
    @SpringBootApplication
    @ImportResource("classpath:provider.xml")
    public class ZDubboService1Application {
    
        public static void main(String[] args) {
            SpringApplication.run(ZDubboService1Application.class, args);
        }
    }

    4.src/main/resources 下增加provider.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://code.alibabatech.com/schema/dubbo
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
        <!-- 服务应用名称 -->
        <dubbo:application name="provider"/>
        <!-- 使用zookeeper做为注册中心 -->
        <dubbo:registry  protocol="zookeeper" address="zookeeper://127.0.0.1:2181"/>
        <!-- ref中的值要跟服务实现类中的@Server的值一致 -->
        <dubbo:service interface="com.example.demo.DubboService" ref="DubboService"></dubbo:service>
    </beans>
  • 相关阅读:
    SQL Server临时表的使用方案
    SqlServer 临时表
    SqlServer 数据表数据移动
    IQ/OQ/DQ/PQ
    (转)C# WebApi 跨域问题解决方案:CORS
    (转).Net高级进阶,在复杂的业务逻辑下,如何以最简练的代码,最直观的编写事务代码?
    (转)C#动态webservice调用接口
    (转)wsdl文件用SoapUI快速创建WebService,CXF生成客户端代码
    (转)C# Oracle数据库操作类
    (转)C#连接Oracle数据库(直接引用dll使用)
  • 原文地址:https://www.cnblogs.com/rigid/p/8000786.html
Copyright © 2011-2022 走看看