Java SpringXML配置和名称空间

Java SpringXML配置和名称空间,java,xml,spring,configuration,Java,Xml,Spring,Configuration,我正在尝试配置一个Spring配置(xml)文件,并尝试为一个有效的模式文件添加一个名称空间,该文件位于我的项目中的本地。原因是我没有一个“真实”的URL(web服务器等),所以我尝试使用一个本地模式,我将在web-INF/下提供该模式: MyProject/ src/ java/ config/ MySchema.xsd spring-config.xml build.xml 在myspring

我正在尝试配置一个Spring配置(xml)文件,并尝试为一个有效的模式文件添加一个名称空间,该文件位于我的项目中的本地。原因是我没有一个“真实”的URL(web服务器等),所以我尝试使用一个本地模式,我将在
web-INF/
下提供该模式:

MyProject/
    src/
        java/
        config/
            MySchema.xsd
            spring-config.xml
    build.xml
在my
spring config.xml中:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:ms="http://myproject.org/MySchema.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
   http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
最后,我希望
spring config.xml
MySchema.xsd
都存储在
WEB-INF/
下,所以我不确定spring为什么要查看
META-INF/
。。。有什么想法吗

URL
http://myproject.org/MySchema.xsd
不是真正的URL,只是为模式提供了自己的名称空间。提前谢谢

xsi:schemaLocation属性中没有对的“定义”(我不知道正确的术语)。试着这样做:

xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://myproject.org/MySchema.xsd location/of/MySchema.xsd">

是否需要定义
spring.schema
spring.handlers

请参阅此处的更多信息:

您还需要为
http://myproject.org/MySchema.xsd
。在W3C中,架构位置:

由一对或多对URI引用组成,由空格分隔。每对的第一个成员是名称空间名称,第二个成员是一个提示,描述在何处找到该名称空间的适当模式文档。这些提示的存在不要求处理者获取或使用引用的模式文档,并且处理者可以自由使用通过任何合适的方式获得的其他模式,或者根本不使用模式


我将使用不同的名称空间名称,以免与名称空间模式文档提示混淆。可能使用模式位置,例如
http://myproject.org/my-schema 改为config/MySchema.xsd

这是SAX在
META-INF
中查找xsd,而不是Spring。
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://myproject.org/MySchema.xsd location/of/MySchema.xsd">