我想委託我的項目在Spring Security中的安全性,但是當我將依賴關係添加到我的POM並啓動服務器時,我得到一個無意義的錯誤......它表示我applicationContext.xml中有一個錯誤,它指向的地方,我有一個AOP句行...AOP彈簧安全錯誤
這裏是我的applicationContext.xml的簡化版本
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<!-- Activates scanning of @Autowired -->
<context:annotation-config/>
<!-- Activates scanning of @Repository and @Service -->
<context:component-scan base-package="es.myproject"/>
<!-- datasource configuration -->
<context:property-placeholder location="classpath:jdbc.properties" />
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${jndi.name}" />
<property name="lookupOnStartup" value="true"></property>
<property name="cache" value="true"></property>
<property name="proxyInterface" value="javax.sql.DataSource"></property>
</bean>
<!-- hibernate session factory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
<property name="packagesToScan" value="es.myproject.modelo.datos" />
</bean>
<!-- enable the configuration of transactional behavior based on annotations -->
<aop:aspectj-autoproxy />
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>
這些是德依賴性:
<!-- Spring security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
錯誤點<aop:aspectj-autoproxy />
applicationContext.xml中
如果我刪除了Spring安全依賴關係,錯誤消失......怪異的吧?任何人的想法?
錯誤說: org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/aop/spring-aop-3.1.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 41 in XML document from ServletContext resource [/WEB-INF/classes/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'aop:aspectj-autoproxy'.
但目前還沒有真正的問題與讀取XSD,正如我說的,如果我刪除了春天的安全依賴這個錯誤不顯示...
偉大的!我的pom.xml缺少spring-aop,spring-context和spring-web,一旦我更新它,服務器就像一個魅力開始:)謝謝! – diminuta 2012-07-12 10:18:26
您是否嘗試過使用Maven依賴關係(mvn dependency:tree)來檢查您的依賴關係? – gffny 2013-12-21 02:47:43