2014-01-16 66 views
0

我在Spring項目上得到以下異常。即使我嘗試了幾個解決方案,建議在stackoverflow我無法解決。你可以幫我嗎 ?無法找到名稱空間NamespaceHandler(http://www.springframework.org/schema/context)

java.lang.Exception的:java.lang.IllegalStateException:ContainerBase.addChild:啓動:org.apache.catalina.LifecycleException:org.springframework.beans.factory.parsing.BeanDefinitionParsingException:配置問題:找不到NamespaceHandler命名空間[http://www.springframework.org/schema/context] 違犯的資源:類路徑的資源[springDAO.xml]

SpringDao.xml

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:jee="http://www.springframework.org/schema/jee" 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:lang="http://www.springframework.org/schema/lang" 
xmlns:util="http://www.springframework.org/schema/util" 
xmlns:tx="http://www.springframework.org/schema/tx" 
xmlns:aop="http://www.springframework.org/schema/aop" 
xmlns:amq="http://activemq.org/config/1.0"  
xsi:schemaLocation=" 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd 
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd 
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd 
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd 
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd 
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd 
http://activemq.org/config/1.0 http://activemq.apache.org/schema/core/activemq-core-5.0-SNAPSHOT.xsd" 
default-autowire="autodetect"> 

<!-- Database --> 
<bean id="ds" class="org.springframework.jndi.JndiObjectFactoryBean" autowire="no"> 
    <property name="jndiName" value="java:comp/env/jdbc/datasource" /> 
</bean> 

<bean id="entityManagerFactory" 
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
    <property name="dataSource" ref="ds" /> 
    <property name="persistenceUnitName" value="NewstrackPU"/> 
    <property name="loadTimeWeaver"> 
     <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" /> 
    </property> 
    <property name="jpaVendorAdapter"> 
     <bean 
      class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">     
     </bean> 
    </property>   
    <property name="jpaDialect"> 
     <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" /> 
    </property> 
</bean> 

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> 
    <property name="entityManagerFactory" ref="entityManagerFactory"/> 
</bean> 
<!-- tx:annotation-driven configure transactions on any beans with @Transactional, and just after the JPA transaction manager is setup. --> 
<tx:annotation-driven transaction-manager="transactionManager"/> 
<context:component-scan base-package ="com.abc.newstrack.dao"/> 
<context:component-scan base-package ="com.abc.newstrack.service"/> 

Spring的依賴

<dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring</artifactId> 
     <version>2.5.6.SEC03</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
     <version>2.5.6.SEC03</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>2.5.6.SEC03</version> 
    </dependency> 
+0

你的類路徑中既有spring又有spring-context。不要使用彈簧(其中幾乎包含所有內容)或使用單獨的模塊(彈簧上下文等)。還要確保你在yuor classpath中沒有衝突的spring版本(請查看'mvcn depenency:tree')。 –

+0

謝謝Deinum。這似乎是一個矛盾的問題,我正在解決它。 – Duleendra

回答

0

我下載了activemq-core-5.0-SNAPSHOT的pom.xml。它使用Spring 2.0.6作爲依賴項。我看到你有Spring 2.5.6 SEC02作爲你的spring依賴。

基於activeMQ pom文件,我相信你將不得不使用spring 2.0.6作爲依賴而不是2.5.6?

至於你的命名空間的實際問題沒有得到解決,它通常是一個與類路徑中不存在依賴關係有關的問題。在這種情況下,因爲活動mq使用Spring 2.0.6,它不在類路徑中。

相關問題