我們有一個自定義的安全jar,它由另一個團隊的spring security core和spring security cas構建而成,我們希望將它添加到我們的Grails項目中。我將<import resource=classpath:META-INF/security.xml>
標記添加到我的applicationContext.xml中,並嘗試添加所需的xmlns和xsd聲明,但它給了我一個錯誤。將自定義jar添加到grails項目
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]
我們必須手動添加彈簧安全爲核心,彈簧安全-conf的依賴,當我們升級了純Java項目中使用這個罐子,做我們需要做同樣的Grails中還是有更好的方法?
Grails的2.2 Groovy的2.0.6
而且security.jar被用在Spring Security 3.0
任何指導建?我已經瀏覽了我們擁有的三本Grails書籍,並且沒有涉及將自定義庫添加到項目中的問題。
謝謝。
編輯1.
新增春季安全依賴於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文件中看到有問題的類,所以我知道它在那裏。
所以我添加這些 運行 「org.springframework.security:spring-security-core:3.1.4.RELEASE」 運行 「org.springframework.security:spring-security-config:3.1.4.RELEASE」 到我的BuildConfig,但它說錯誤未能解決。 – idonaldson
無論以前的評論如何,如果你把它們放在正確的部分,它會有所幫助。我有他們在插件下,他們顯然屬於依賴。 – idonaldson
我設法使用一個私人maven回購協議,但是當我嘗試將導入添加到ApplicationContext.xml時,我得到一個ClassNotFoundException異常。在grails中導入資源是否有不同的方式? – idonaldson