I'm using grails 3.3.0 with rest api and gson views. I have the following setup...
Domain Class
package foo
@Resource(uri="/api/bars", readOnly = false, formats = ['json', 'xml'])
class Bar{
String firstName
String lastName
}
Controller:
package foo
class BarController extends RestfulController<Building>{
def show(){
respond Bar.get(params.id)
}
}
_bar.gson:
import foo.Bar;
model {
Bar bar
}
json {
name bar.firstName
}
_show.gson:
import foo.Bar;
model {
Bar bar
}
json g.render(template:"bar", model:[bar:bar])
directory layout:
/grails-app/views/
-----------------bar/
--------------------_bar.gson
--------------------_show.gson
This fails during build
, test
, compile
and war
with the following error:
Execution failed for task ':compileGsonViews'.
foo_bar_show_gson: 3: unable to resolve class foo.Bar
I followed the documentation but I cannot get around this. Please help!