Grails Geocode plugin dependency injection issue

2019-09-03 10:22发布

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条回答
够拽才男人
2楼-- · 2019-09-03 10:50

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.

查看更多
登录 后发表回答