spring dubbo搭建常用pom配置

本文介绍了如何在Spring环境中配置Dubbo,包括在DubboDemo模块的pom.xml添加JUnit和LOG4J依赖,provider模块引入Spring、Dubbo、interface模块依赖,并配置log4j.properties。详细讲解了spring-provider.xml和spring-consumer.xml的配置,涉及application、registry、protocol、service等关键参数。最后说明了consumer如何引用provider服务并启动测试。
摘要由CSDN通过智能技术生成

在 DubboDemo 模块 pom.xml 加入如下依赖,为所有模块提供 JUnit 和 LOG4J 依赖。

<!-- **************************** Properties 配置 **************************** -->
    <properties>
        <junit.version>3.8.1</junit.version>
    </properties>
    <!-- **************************** /Properties 配置 **************************** -->

  <dependencies>
      <!-- **************************** JUnit 依赖 **************************** -->
      <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>${junit.version}</version>
          <scope>test</scope>
      </dependency>
      <!-- **************************** /JUnit 依赖 **************************** -->

      <!-- **************************** 日志 依赖 **************************** -->
      <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
          <version>1.7.6</version>
      </dependency>
      <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
          <version>1.7.6</version>
      </dependency>
      <!-- **************************** /日志 依赖 **************************** -->
  </dependencies>

同时在 provider 模块和 consumer 模块的 resources 目录里加入 log4j.properties 配置文件:

#Console Log
log4j.rootLogger=info, console, file

# Write to Console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.Threshold=INFO
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%5p %d{MM-dd HH:mm:ss}(%F:%L): %m%n

#Write to File
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.File=${catalina.home}log/provider.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%5p %d{MM-dd HH:mm:ss}(%F:%L): %m%n

在 provider 模块中引入 Spring、Dubbo、interface 模块依赖:

<!-- **************************** Properties 配置 **************************** -->
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <junit.version>3.8.1</junit.version>
        <springframework.version>4.1.6.RELEASE</springframework.version>
        <commonsLogging.version>1.2</commonsLogging.version>
    </properties>
    <!-- **************************** /Properties 配置 **************************** -->

    <dependencies>
        <!-- **************************** Spring 依赖 **************************** -->
        <!-- 添加Spring-core包 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <!-- 添加spring-tx包 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <!-- Spring ORM 相关-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值