---
title: " zkspring 3.0RC bug 修复"
author: "sunflowers"
date: "2010-11-19T15:46:15Z"
tags: []
categories: ["编程语言"]
slug: "zkspring-3-0rc-bug"
draft: false
lastmod: "2010-11-19T16:03:33Z"
id: 816337
url: "https://sunflowers.iteye.com/blog/816337"
---

zkspring 3.0RC bug 修复

 

一，bug展示：

 

当你如下配置使用zksp-annot注解时，你会在控制台看到如下错误

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: 

Configuration problem: Unable to locate Spring NamespaceHandler for XML schema 

namespace \[http://www.zkoss.org/2008/zkspring-annot]

 

配置信息

 

```
<?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:jee="http://www.springframework.org/schema/jee"
	xmlns:tx="http://www.springframework.org/schema/tx" 
	xmlns:util="http://www.springframework.org/schema/util"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
	http://www.springframework.org/schema/tx
	http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
	http://www.springframework.org/schema/jee
	http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
	http://www.springframework.org/schema/aop
	http://www.springframework.org/schema/aop/spring-aop-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/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
	http://www.springframework.org/schema/util
	http://www.springframework.org/schema/util/spring-util-3.0.xsd
	http://www.zkoss.org/2008/zkspring-annot
	http://www.zkoss.org/2008/zkspring-annot/zkspring-annot.xsd
	http://www.zkoss.org/2008/zkspring/core
    http://www.zkoss.org/2008/zkspring/core/zkspring-core.xsd"
    xmlns:zksp="http://www.zkoss.org/2008/zkspring/core"
    xmlns:zksp-annot="http://www.zkoss.org/2008/zkspring-annot">
    <zksp-annot:component-scan base-package="org.zkway"></zksp-annot:component-scan>
    <zksp:zk-config>
   </zksp:zk-config>
	
</beans>
```

 

 

二，bug出错的原因

 

在（一）中出现这种错误的原因是因为spring无法解析zksp-annot命名空间

 

命名空间的处理在zkspring-core.jar!/meta-inf目录内(7-zip,winrar打开可疑查看)

 

spring.schemas指定了xsd的位置

 

spring.handlers指定了命名空间的处理类

 

但是在这两个配置文件里仅仅配置了zkspring-core的处理细节，

并未配置zkspring-annot,所以在解析的时候，spring无法处理该命名空间而报错

 

 

三，解决办法

 

在spring.handlers文件内添加如下代码

 

http\\://www.zkoss.org/2008/zkspring-annot=org.zkoss.spring.config.ZkSpringAnnotationNamespaceHandler

 

在spring.schemas文件内添加如下代码http\\://www.zkoss.org/2008/zkspring-annot/zkspring-annot.xsd=metainfo/xml/zkspring-annot.xsd

 

然后使用(7-zip,winrar)打开zkspring。jar，将修改后的文件替换掉zkspring-core.jar!/meta-inf目录内的文件即可