Grails Geocode plugin dependency injection issue

元气小坏坏 提交于 2019-12-12 03:08:11

问题


Grails Version: 3.0.7

Groovy Version: 2.4.4

JVM Version: 1.8.0_51

I must be missing something really simple here.

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 :

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

The relevant line of code is :

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?


回答1:


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

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

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 plugins : https://bintray.com/grails/plugins Grails 2.x plugins : https://grails.org/plugins/

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 >

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

Hope this helps should anyone else encounter this.



来源:https://stackoverflow.com/questions/34394977/grails-geocode-plugin-dependency-injection-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!