将自定义jar添加到grails项目

时间:2013-06-25 17:34:09

标签: spring grails grails-2.0

我们有一个自定义安全jar,它是由另一个团队的spring security core和spring security cas构建的,我们希望将它添加到我们的Grails项目中。我将<import resource=classpath:META-INF/security.xml>标记添加到我的applicationContext.xml并尝试添加所需的xmlns和xsd声明,但它给了我一个错误。

Message: Configuration problem: Failed to import bean definitions from URL location [classpath:META-INF/security.xml]
Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security]
Offending resource: class path resource [META-INF/security.xml]

当我们升级纯Java项目以使用这个jar时,我们不得不手动添加spring-security-core,spring-security-conf依赖项,我们是否需要对Grails执行相同的操作,还是有更好的方法?< / p>

Grails 2.2 Groovy 2.0.6

security.jar是使用Spring Security 3.0构建的

任何指导?我查看了我们拥有的三本Grails书籍,而不是其中一本涉及向项目添加自定义库的内容。

感谢。

编辑1。

将Spring安全依赖项添加到BuildConfig.groovy文件中,如下所示

    dependencies {
    compile "org.springframework.security:spring-security-core:3.1.4.RELEASE"
    compile "org.springframework.security:spring-security-config:3.1.4.RELEASE"
}

这似乎让我超越了旧的错误。但现在我得到了可爱的

Error 2013-06-25 16:20:34,982 [localhost-startStop-1] ERROR context.ContextLoader  - Context initialization failed
Message: Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'userService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [edu.umt.security.NetIdAuthoritiesPopulator] for bean with name 'userService' defined in class path resource [META-INF/security.xml]; nested exception is java.lang.ClassNotFoundException: edu.umt.security.NetIdAuthoritiesPopulator
...
Caused by CannotLoadBeanClassException: Cannot find class [edu.umt.security.NetIdAuthoritiesPopulator] for bean with name 'userService' defined in class path resource [META-INF/security.xml]; nested exception is java.lang.ClassNotFoundException: edu.umt.security.NetIdAuthoritiesPopulator

通常我们通过几次清理eclipse项目来解决这个问题,它会自行解决,这次没有骰子,我不确定问题出在哪里。我可以在jar文件中看到有问题的类,所以我知道它就在那里。

1 个答案:

答案 0 :(得分:1)

如果Maven仓库中没有jar,并且您无法在BuildConfig.groovy中添加依赖项,则可以将其添加到lib目录中,但不会自动发现它。运行grails compile --refresh-dependencies将其添加到类路径中。

相关问题