微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java.net.MalformedURLException:未知协议:classpath

我试图在spring中使用schemalocation classpath从本地驱动器导入xsd架构.我在类路径中添加了所需的文件,并添加了此文件的引用

15:10:19.336 [localhost-startStop-1] DEBUG o.s.b.f.xml.ResourceEntityResolver - Could not resolve XML entity [classpath:spring-social-facebook-1.1.xsd] against system root URL
java.net.MalformedURLException: unkNown protocol: classpath
    at java.net.URL.Nown Source) ~[na:1.8.0_31]
    at java.net.URL.Nown Source) ~[na:1.8.0_31]
    at java.net.URL.Nown Source) ~[na:1.8.0_31]

这是我的applicationContext.xml的标题,

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/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-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/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
            http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.7.xsd
            http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
            http://www.springframework.org/schema/social http://www.springframework.org/schema/social/spring-social.xsd
            http://www.springframework.org/schema/social/facebook classpath:spring-social-facebook-1.1.xsd">

我使用的是Spring 4.1和spring-bean 3.0版.

最佳答案
你不应该搞乱其他地方并使用认值.对于Spring Social Facebook,您应该使用http://www.springframework.org/schema/social/spring-social-facebook-1.1.xsd,或者最好使用少一个版本http://www.springframework.org/schema/social/弹簧社会facebook.xsd.

Spring将始终首先从类路径中加载jar中的xsd. Spring附带了一个自定义的EntityResolver,即PluggableSchemaResolver,它使用Spring jar文件meta-inf目录中的不同spring.schemas文件.

获得错误的唯一原因(以及为什么要尝试解决它)是

>你没有包括spring-social-facebook所需的依赖项
>你已经包含了错误的spring-social-facebook依赖项
>您使用的是不兼容的Spring和Spring Social版本.

我打赌选项2没有所有1.1.0版本的spring-social-facebook但混合版本的jar.

原文地址:https://www.jb51.cc/spring/431930.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐