0

In my custom Grails plugin, how can I set up a JSON view for a non-domain class and get client apps to use it by default?

I have a view file in the plugin:

/views/com/mycompany/myplugin/myclass/_myClass.gson

When I do grails install, I can see that this .gson file is in the generated JAR. However, the client app is not using it.

What can I do to make it work?

Are there any settings or steps that can make troubleshooting easier?

I am using Grails 3.2.4.

Update:

When I copy the view into a client app, using the exact same path, the view is getting invoked. It's only when the view is defined in the plugin that the view cannot be found.

The framework seems to be trying to look up the plugin as a class from the classloader: myclientproject_com_mycompany_myplugin_myclass__myClass_gson How do I get my plugin to add this class to the classpath?

4

1 回答 1

0

对于我的用例,我真正需要的是一个自定义转换器。

看:

在 JSON 视图中,如何将对象展平为单个字符串?

这消除了我的插件发布视图的需要。

于 2017-03-27T20:12:09.800 回答