grails发布插件错误“找不到类加载插件资源[spring.resources]”

时间:2012-11-15 16:08:22

标签: grails publish

当发布我使用“Realease-2.0.4”和Grails 2.0.1构建的特定插件时,我得到一个奇怪的异常,我似乎无法摆脱它。我有许多插件具有类似的设置,并且这些插件都不会产生此异常。

| Error 2012-11-15 17:00:25,604 [main] ERROR plugins.DefaultGrailsPlugin  - Class not found loading plugin resource [spring.resources]. Resource skipped.
Message: spring.resources
   Line | Method
->> 202 | run       in java.net.URLClassLoader$1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   190 | findClass in java.net.URLClassLoader
|   306 | loadClass in java.lang.ClassLoader
|   247 | loadClass in     ''
|   178 | doCall .  in _PluginDependencies_groovy$_run_closure5_closure23
|   176 | doCall    in _PluginDependencies_groovy$_run_closure5
|    60 | doCall .  in _GrailsPackage_groovy$_run_closure2
|    45 | doCall    in PublishPlugin$_run_closure1
^    62 | doCall .  in     ''
| Error 2012-11-15 17:00:25,977 [main] ERROR plugins.DefaultGrailsPlugin  - Class not found loading plugin resource [spring.resources]. Resource skipped.
Message: spring.resources
   Line | Method
->> 202 | run       in java.net.URLClassLoader$1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   190 | findClass in java.net.URLClassLoader
|   306 | loadClass in java.lang.ClassLoader
|   247 | loadClass in     ''
|   178 | doCall .  in _PluginDependencies_groovy$_run_closure5_closure23
|   176 | doCall    in _PluginDependencies_groovy$_run_closure5
|    60 | doCall .  in _GrailsPackage_groovy$_run_closure2
|    45 | doCall    in PublishPlugin$_run_closure1
^    62 | doCall .  in     ''

这就是堆栈跟踪的全部内容。

在grails-app / conf / spring / resources下没有定义资源。

我知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

1.Context

我使用grails 2.4.3和java 1.7开发一个自定义插件并在应用程序中使用它。自定义插件使用 spring-security-core 插件并添加了一些功能。该应用程序使用自定义插件并添加其他功能。这个想法是在自定义插件中设置spring-security和其他常见功能,并在多个项目中使用它。

当我在 conf / BuildConfig.groovy 文件中运行具有下一个配置的应用程序时,没有问题:

...
grails.plugin.location.'author-security-plugin' = "../AuthorSecurityPlugin"
...

然而,当我打包插件并使用下一个命令将其安装在我的maven本地存储库中时:

$ grails clean
$ grails refresh-dependencies
$ grails maven-install

conf / BuildConfig.groovy 文件中使用下一个配置:

dependencies {
    // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
    compile: ':domino-connection-lib:'
    runtime: 'postgresql:postgresql:9.2-1002.jdbc4'

    //custom plugin
    compile: "com.company:author-security-plugin:0.1"
}
...
//grails.plugin.location.'author-security-plugin' = "../AuthorSecurityPlugin"
...

执行¨grailsstart-app¨命令,该项目抛出下一个异常:

| Packaging Grails application.....
2015-04-20 17:12:42,067 [main] ERROR plugins.DefaultGrailsPlugin  - Class not found loading plugin resource [spring.resources]. Resource skipped.
java.lang.ClassNotFoundException: spring.resources
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at _PluginDependencies$_run_closure2.doCall(_PluginDependencies.groovy:48)
at _GrailsPackage$_run_closure2.doCall(_GrailsPackage.groovy:57)
at RunApp$_run_closure1.doCall(RunApp.groovy:28)

注意: spring / resources.groovy 文件包含:

// Place your Spring DSL code here
beans = {
    customAuthenticationProvider(CustomAuthenticationProvider){
        springSecurityService=ref('springSecurityService')
        customUserService=ref('customUserService')
    }
    ...
}

2.解决方案

在我的情况下,解决方案是在自定义插件中删除grails-app / conf / spring / resources.groovy文件,并在应用程序中将其内容移至grails-app / conf / spring / resources.groovy。

我希望这可以帮到你。