Grails 依赖解析
我是一个 Grails 新手。我有一个在 Eclipse 中运行良好的应用程序,但当我在生产中部署时,由于缺少依赖项而失败。
当我运行依赖关系报告时,它显示所有依赖关系都自动存在于“构建”中,但不存在“运行时”中。
将依赖项从运行时迁移到运行时(以便(我希望)将它们复制到我的 war 文件中)的最简洁方法是什么?
另外,我正在使用消毒剂插件。这在开发中运行良好,但“运行时”缺少依赖项,因此失败了。例如,如果我手动将依赖项之一添加到 BuildConfig.groovy ("org.owasp.antisamy:antisamy:1.4.3") 中,则 grails 会出现以下错误:
加载程序约束违规:加载程序( 的实例)先前启动加载名称为“org/xml/sax/SAXParseException”的不同类型
我假设这是一个类路径问题,但我不确定为什么只有在我手动添加依赖项时才会发生这种情况 - 当然它一直存在?
I'm a bit of a Grails newbie. I have an app which works fine in Eclipse but when I deploy in production falls over because of missing dependencies.
When I run the dependency report it shows all the dependencies are automatically present for 'build' but absent for 'runtime'.
What's the neatest way to migrate the dependencies from to runtime so (I hope) they get copied into my war file?
Also, I'm using the sanitizer plugin. This runs fine in development but has the dependencies missing from 'runtime' so falls over. If I manually add, for example, one of the dependencies into BuildConfig.groovy ("org.owasp.antisamy:antisamy:1.4.3") then grails falls over with this error:
loader constraint violation: loader (instance of ) previously initiated loading for a different type with name "org/xml/sax/SAXParseException"
I'm assuming that this is a classpath issue but I'm not sure why this only happens when I manually add the dependency - surely it's present all the time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是对的,你必须将缺少的运行时依赖项添加到 BuildConfig.groovy 中。最简单的事情是将它们从插件的 BuildConfig.groovy 复制到您的应用程序的。您还应该为相应的 grails 插件启动 JIRA,以修复上游问题。
Maven 存储库中的许多 jar 的依赖项未在其 pom 文件中正确定义。
在 BuildConfig.groovy 中有一种方法可以通过关闭传递性来解决这个问题:
除了“transitive=false”之外,您还可以尝试使用
“运行时”闭包内的“例如”仅排除特定依赖项。
You're right, you have to add missing runtime dependencies to BuildConfig.groovy. The simplest thing would be to copy them from the plugin's BuildConfig.groovy to your app's one. You should also raise a JIRA for the respective grails plugin to get this fixed upstream.
Lots of jars out there in the Maven repositories have their dependencies not correctly defined in their pom file.
There is a way to fix that in BuildConfig.groovy, by switching off transitivity:
Instead of 'transitive=false' you might also experiment with excluding only specific dependencies using e.g.
inside the 'runtime' closure.