Tôi đã gặp lỗi này gần một tuần rồi và chỉ cần sẵn sàng cho vào. Tôi đã sử dụng Maven2 để tạo tệp jar lớn. Khi tôi chạy file jar sử dụng:không thể xác định lỗi Spring NamespaceHandler
java -jar someJar.jar
tôi nhận được lỗi này:
ERROR: [27/55/13 10:55] Launcher: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [JavaProjectApplicationContext.xml]
JavaProjectApplicationContext.xml là như sau:
<?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:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location"><value>deployment.properties</value></property>
</bean>
<bean id="LexEditorDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"><value>${hibernate.jdbc_driver}</value></property>
<property name="username"><value>${hibernate.username}</value></property>
<property name="password"><value>${hibernate.password}</value></property>
<property name="url"><value>${hibernate.url}</value></property>
<property name="defaultAutoCommit"><value>${hibernate.default_auto_commit}</value> </property>
<property name="maxActive"><value>20</value></property>
<property name="maxIdle"><value>3</value></property>
<property name="testOnBorrow"><value>true</value></property>
<property name="testOnReturn"><value>true</value></property>
<property name="testWhileIdle"><value>true</value></property>
</bean>
<context:component-scan base-package="com.k_int.bank.plugin">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/>
</context:component-scan>
<bean id="ThesSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource"><ref local="LexEditorDataSource"/></property>
<property name="configurationClass"> <value>org.hibernate.cfg.AnnotationConfiguration</value></property>
<property name="packagesToScan">
<list>
<value>com.bank.kernel.datamodel</value>
</list>
</property>
<property name="annotatedClasses">
<list>
<!-- identity service -->
<value>com.svc.identity.datamodel.PartyHDO</value>
<value>com.svc.identity.datamodel.RegisteredUserHDO</value>
<value>com.svc.identity.datamodel.AuthenticationDetailsHDO</value>
<value>com.svc.identity.datamodel.GrantHDO</value>
<value>com.svc.identity.datamodel.PermissionHDO</value>
<value>com.svc.identity.datamodel.RegisteredOrganisationHDO</value>
<value>com.svc.identity.datamodel.RoleHDO</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
</bean>
<bean id="IndexService" class="com.k_int.bank.index.solr_impl.SOLRIndexService" init-method="init">
<property name="indexDirectory"><value>${com.bank.index_dir}</value></property>
<property name="indexPropertyFile"><value>solr.properties</value></property>
</bean>
Những điều tôi đã cố gắng cho đến nay.
xây dựng dự án theo 3 cách khác nhau (2 IDE và dòng lệnh) xóa bất kỳ xung đột phụ thuộc jar nào (tôi đã có spring-2.5.6.jar và spring-context-3.0.5.RELEASE.jar, vì vậy tôi đã xóa spring-2.5.6.jar)
thay đổi http://www.springframework.org/schema/beans/spring-beans-2.5.xsd thành http://www.springframework.org/schema/beans/spring-beans-3.0.xsd.
Không có thay đổi nào trong số này đã xóa lỗi.
Trong tập tin tồn tại trong xe
someJar.jar/org/springframework/context/config/ContextNameSpaceHandler.class
Có ai có bất kỳ ý tưởng nào cả.
Bạn đã thay đổi 'beans' namespace URI, nhưng được thông báo lỗi là về' namespace context'. Hãy thử loại bỏ thông tin phiên bản khỏi URI được ánh xạ (như 'http: // www.springframework.org/schema/context/spring-context.xsd') mà nên được giải quyết thành phiên bản mới nhất của tệp .xsd trong ngữ cảnh mùa xuân của bạn. jar. – zagyi
xin lỗi tôi đã thay đổi ngữ cảnh mùa xuân. Tôi đã thử những gì bạn đã nói vẫn không có may mắn. – Sagarmichael