当前位置: 首页 > 知识库问答 >
问题:

无法找到命名空间的NamespaceHandler(http://www.springframework.org/schema/context)

仲俊豪
2023-03-14
<?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>

共有1个答案

郗浩
2023-03-14

我下载了activemq-core-5.0-snapshot pom.xml。它使用Spring2.0.6作为依赖项。我看到您有Spring2.5.6 SEC02作为您的Spring依赖项。

基于activeMQ pom文件,我相信您必须使用spring 2.0.6作为依赖项,而不是2.5.6?

至于名称空间未被解决的实际问题,通常是类路径中不存在依赖项的问题。在本例中,由于active mq使用Spring2.0.6,所以它不在类路径中。

 类似资料: