Grails-Camel 插件无法安装或运行

标签 grails apache-camel grails-plugin

请注意:虽然这个问题涉及一个名为 Apache Camel 的库。我真的认为这只是一个关于现代 Grails 插件如何工作的问题。

我在这里使用 Grails 2.4.2,我正在尝试将 Apache Camel 与 Grails 一起使用,发现 Grails Routing插件,甚至无法安装它。

说明通过发出 grails install-plugin routing 进行安装.当我这样做时,我得到:

grails install-plugin routing
Starting process on LT-IE-ZH/10.10.99.14
Loading Grails 2.4.2
|Configuring classpath
.
|Environment set to development
......Warning 
|
Since Grails 2.3, it is no longer possible to install plugins using the install-plugin command.
Plugins must be declared in the grails-app/conf/BuildConfig.groovy file.
Example:
grails.project.dependency.resolution = {
    ...
    plugins {
        compile ":routing:1.3.2"
    }
}

所以我修改了我的BuildConfig.groovy像这样:
plugins {
    // plugins for the build system only
    build ":tomcat:7.0.54"

    compile ":routing:1.3.2"

    ...lots of other stuff omitted for brevity

}

然后插件说要创建路由,发出 grails create-route <RouteName> .所以我就是这样做的:
grails create-route OrderListener
Starting process on LT-IE-ZH/10.10.99.14
Loading Grails 2.4.2
|Configuring classpath
|Running pre-compiled script
|Script 'CreateRoute' not found, did you mean:
    1) CreateFilters
    2) CreatePom
    3) CreateApp_
    4) CreateController
    5) CreateHibernateCfgXml
Please make a selection or enter Q to quit: 

这里发生了什么?!? 我如何安装/使用这个插件?!?我是疯了,还是这个插件根本不起作用?

更新

我跑grails clean-all ,然后 grails refresh-dependencies然后 grails create-route OrderListener我得到:
Loading Grails 2.4.2
.
|Environment set to development
.....Error 
|
groovy.lang.MissingMethodException: No signature of method: CreateRoute.createArtifact() is applicable for argument types: () values: []
Error |
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Error |
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
Error |
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
Error |
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
Error |

<huge stacktrace omitted>

Error |
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:207)
Error |
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:68)
Error |
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
Error |
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
Error |
... 68 more

最佳答案

每当您在 BuildConfig.groovy 中进行更改时一定要运行grails compile触发依赖解析,它将下载新的和更新的插件和 jar,并且它还将编译您的代码,这有助于确保事物至少兼容。

但这里的核心问题是插件的 CreateRoute.groovy脚本严重损坏。它缺少一个重要的包含并且不能接近调用 createArtifact正确。在作者解决此问题之前,作为一种解决方法,在您的应用程序的 scripts 中创建一个脚本。名为 CreateCamelRoute.groovy 的文件夹包含以下内容:

includeTargets << grailsScript('_GrailsCreateArtifacts')

target(createCamelRoute: "Creates a new Camel Route.") {
    createArtifact(type: 'Route', path: 'grails-app/routes', name: argsMap.params?.get(0) ?: 'Example', suffix: 'Route')
}

setDefaultTarget(createCamelRoute)

故意将其命名为与原始名称不同,因为如果 Grails 找到两个具有相同名称的名称,它会询问使用哪一个。这样你就可以运行
grails create-camel-route com.foo.bar.OrderListener

它会起作用。请注意,我稍微更改了示例以包含一个包 - 始终使用包:)

关于Grails-Camel 插件无法安装或运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28637407/

相关文章:

hibernate - 如何应对 'org.postgresql.util.PSQLException: No value specified for parameter 1' ?

ide - 如何让 Intellij 停止删除 Grails 内联插件模块依赖项?

hibernate - grails IntegrationSpec:如何使其不回滚

date - Grails-字符串到日期的转换

grails - Grails 2.5.1 domain.get(id)获取缓存的数据

java - 为什么 Camel 在飞行存储库中保留交换?

java - 如何使用多线程使用Camel File Component Consumer

apache-camel - Apache Camel SQL 组件未关闭结果集?

grails - 有没有办法将 Mercurial 代码与所有捆绑的第三方库分开?

grails - 在Grails中按用户保护 Controller Action