gpt4 book ai didi

java - Spring XML 配置和命名空间

转载 作者:行者123 更新时间:2023-11-30 04:58:14 25 4
gpt4 key购买 nike

我正在尝试配置 Spring 配置(xml)文件,并尝试为我本地项目中的有效架构文件添加命名空间。原因是我没有“真实”的 URL(Web 服务器等),所以我尝试仅使用我将在 WEB-INF/ 下提供的本地架构。 :

MyProject/
src/
java/
config/
MySchema.xsd
spring-config.xml
build.xml

在我的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">

项目正在构建和部署良好,但是当我运行它时,我得到:

org.xml.sax.SAXException: Failed to locate XSD resource '/META-INF/MySchema.xsd' on 
classpath. Namespace: 'http://myproject.org/MySchema.xsd'.

最终我都想要spring-config.xmlMySchema.xsd存储在WEB-INF/下,所以我不确定 Spring 为什么要查看内部 META-INF/ ...有什么想法吗?

网址http://myproject.org/MySchema.xsd不是真正的 URL,只是为模式提供了自己的 namespace 。提前致谢!

最佳答案

http://myproject.org/MySchema.xsd 没有“定义”(我不知道正确的术语)在 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">

关于java - Spring XML 配置和命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7797163/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com