简体   繁体   English

Grails 3.3.0是否在插件中支持拦截器?

[英]Does Grails 3.3.0 support interceptors in plugins?

I created a Grails plugin which is used by my Grails app. 我创建了一个Grails插件,供我的Grails应用程序使用。 I created an interceptor "TestInterceptor" in grails-app/controllers in the plugin. 我在插件的grails-app / controllers中创建了一个拦截器“ TestInterceptor”。 I used 'grails install' to install the plugin to my local maven repository. 我使用“ grails install”将插件安装到本地maven存储库。

When I run the app, the interceptor is not invoked. 当我运行该应用程序时,不会调用拦截器。

When I examine the generated META-INF/grails-plugin.xml within my plugin JAR, the interceptor is not present. 当我检查插件JAR中生成的META-INF / grails-plugin.xml时,不存在拦截器。 Other artefact types (services, controllers, domains) are present in grails-plugin.xml. grails-plugin.xml中还存在其他伪像类型(服务,控制器,域)。

If I move the interceptor to my app, it gets invoked. 如果将拦截器移动到我的应用程序,则会被调用。

Does Grails 3.3.0 support interceptors in plugins? Grails 3.3.0是否在插件中支持拦截器? If so, what steps do I need to take to get the plugin to publish the interceptor so it gets loaded by my app? 如果是这样,我需要采取什么步骤来使插件发布拦截器,以便其被我的应用加载?

I found another plugin in github with an interceptor and identified that my plugin was missing a required dependency in build.gradle. 我在github中找到另一个带有拦截器的插件,并确定我的插件在build.gradle中缺少必需的依赖项。 Namely, org.grails:grails-plugin-interceptors. 即,org.grails:grails-plugin-interceptors。

This seems obvious now, though I can't say why my plugin was missing that dependency. 现在这似乎很明显,尽管我不能说为什么我的插件缺少该依赖性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM