Grails3添加dubbo分布式框架

grails3以上没有了很多配置文件,导致配置时走了一些弯路

官方文档对这些提的也不是太多

1)在新建的grails3.x项目中,引入dubbo依赖

// log4j2 compile 'org.apache.logging.log4j:log4j-core:2.4.1' compile 'org.apache.logging.log4j:log4j-api:2.4.1' compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.4.1' compile ('com.alibaba:dubbo:2.5.3') { exclude(group:"org.springframework",module: 'spring') exclude(module: 'log4j') } compile ('org.apache.zookeeper:zookeeper:3.4.6') // https://mvnrepository.com/artifact/com.github.sgroschupf/zkclient compile 'com.github.sgroschupf:zkclient:0.1'

如果不去除dubbo依赖的spring和log4j,后面会引入很多冲突

2)添加dubbo依赖,并将文件命名为resources.xml,放置在/co f/spring目录下

<?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:p="http://www.springframework.org/schema/p" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"

<!-- 提供方应用信息,用于计算依赖关系 --> <dubbo:application name="owlApps" /> <!-- 使用zookeeper注册中心暴露服务地址 --> <dubbo:registry address="zookeeper://localhost:2181" /> <!--<dubbo:protocol name='dubbo' payload='16777216' />--> <!-- 用dubbo协议在20880端口暴露服务 --> <dubbo:protocol name="dubbo" port="20880" /> <!-- 声明需要暴露的服务接口 --> <dubbo:reference interface="com.owl.service.AccountService" id="accountService" check="false"/> <!-- 声明需要暴露的服务接口 --> <dubbo:reference interface="com.owl.service.AuthService" id="authService" check="false"/> <!-- 声明需要暴露的服务接口 --> <dubbo:reference interface="com.owl.service.BMUserService" id="userService" check="false"/>
</beans>

3)controller层引用前,@Resources声明

class TestController { private static Logger logger = Logger.getLogger(this); GrailsApplication grailsApplication

@Resource AuthService authService;

当然,如果真的不写,也没事。

GrailsApplication grailsApplication

AuthService authService;

我试了一下,除了第一次的时候提醒没有找到这个bean,加上后再去掉也没再次报错。

应该是本地缓存的原因导致的第一次失败。

虽然已经去除了dubbo的依赖,但还是有时候出现log4j冲突的问题。如果有人能解决或知晓原因还请告知,感激不尽

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )