Grails Geocode插件依赖项注入问题 [英] Grails Geocode plugin dependency injection issue

查看:92
本文介绍了Grails Geocode插件依赖项注入问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Grails版本:3.0.7

Grails Version: 3.0.7

Groovy版本:2.4.4

Groovy Version: 2.4.4

JVM版本:1.8.0_51

JVM Version: 1.8.0_51

我一定在这里遗漏了一些非常简单的东西.

I must be missing something really simple here.

我已按照自述文件中的定义向我的项目中添加了grails插件:

I've added a grails plugin to my project as defined in the read me :

compile 'org.grails.plugins:geocode:0.3'

我可以看到相关的依赖项已从存储库中删除.

I can see the relevant dependencies have been pulled down from the repository.

但是,当尝试使用以下命令在我的控制器中注入服务时:

However, when trying to inject the service within my controller using :

def geocodingService 

我在执行时收到以下错误:

I receive the following error upon execution :

原因:java.lang.NullPointerException:无法在空对象上调用方法getPoint()

Caused by: java.lang.NullPointerException: Cannot invoke method getPoint() on null object

相关的代码行是:

Point location = geocodingService.getPoint('XXX XXX, UK')

我的猜测是依赖注入失败,但是有人可以告诉我我犯的错误吗?

My guess is the dependancy injection is failing but can anybody please tell me the mistake I am making?

推荐答案

注意:从另一个几乎相同的问题中复制了我的答案...

Note : Copied my answer from another almost identical questions ...

好的,这似乎是我愚蠢地尝试在grails 3.x插件中使用grails 2.x插件的原因.

OK, this seems to be down to me stupidly trying to use a grails 2.x plugin in a grails 3.x plugin.

grails文档中详细介绍了将插件从2.x升级到3.x的各种步骤.

There are various steps to go through to upgrade a plugin from 2.x to 3.x all detailed within the grails documentation.

我的直接解决方案是简单地创建一个新服务并将代码从插件复制到我的应用程序中.工作得很好.

My immediate solution was to simply create a new service and copy the code from the plugin into my application. Worked just fine.

Grails 3.x插件: https://bintray.com/grails/plugins Grails 2.x插件: https://grails.org/plugins/

Grails 3.x plugins : https://bintray.com/grails/plugins Grails 2.x plugins : https://grails.org/plugins/

除非您通过grails网站导航,否则这并不明显.例如,如果您直接从Google进入插件页面,则兼容性显示为2.5.x>

It's not obvious unless you navigate via the grails site. If you come in for example from Google directly to a plugin page, compatibility is shown as 2.5.x >

但是,这实际上意味着大于2.5.x但小于3.x

However, this actually seems to mean greater than 2.5.x but less than 3.x

希望这对其他任何人都有帮助.

Hope this helps should anyone else encounter this.

这篇关于Grails Geocode插件依赖项注入问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆