springboot整合dubbo加上事务注解启动报错的问题

springboot整合dubbo加上事务注解启动报错的问题

如果使用以下方式
在其实现类中加入了事务注解

@Reference(version = "1.0.0", timeout = 30000)
    private ShopService shopService;
@Service(version = "1.0.0")
public class OrderFoodServiceImpl implements OrderFoodService {

则启动时就会报错,提示 无法引入ShopService这个类

application.yml 配置


server:
  port: 8083
spring:
 dubbo:
    application:
      name: com.deng
    registry:
      address: zookeeper://36.155.111.35:2181
    protocol:
      name: dubbo
      port: 20880
    scan: com.deng.dubbo

改之前

现在应该采用xml方式暴露 服务
只要将 服务暴露 发现 改为 这种方式即可。
dubbo-service.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
    http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd">
    <!-- 声明需要暴露的服务接口 -->
    <dubbo:service interface="com.service.OrderService" ref="orderServiceImpl"  timeout="300000"/>
    <dubbo:service interface="com.service.ShopService" ref="shopService"  timeout="300000"/>
</beans>

同理。只要将服务暴露 和 发现 都用这种方式 就可以用事务注解了。

如果有更好的办法,希望大家可以提出来。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值