如何从自定义插件访问域类到另一个?

che*_*eX3 1 grails groovy

我目前正在研究grails项目.我创建了八个不同的插件.每个都有一组Domain类和其他东西.现在,从我的一个插件中,某个Domain类需要从另一个插件访问域类.我该怎么做?我是否必须从其他插件导入域类?如果是这样,怎么样?或者我应该在BuildConfig.groovy中这样做?

请帮忙!

谢谢!

Fab*_*oli 7

简单地在buildconfig中制作需要其他插件域依赖的插件

//buildConfig of plugins need other plugin domains

grails.project.dependency.plugins{
   ...
   compile ':<other-plugin-name>:<other-plugin-version>'
   ...
}
Run Code Online (Sandbox Code Playgroud)

只需在您需要的地方导入正确的包.

如果你经常处理依赖的插件并且你不想经常重新打包它,你可以使用grails.plugin.location而不是grails.project.dependency.plugins来连接它.

在buildConfig中添加

grails.plugin.location.'other-plugin-name' = "/path/to/other/plugin/folder"
Run Code Online (Sandbox Code Playgroud)