java.net.MalformedURLException:未知协议:类路径

java.net.MalformedURLException:未知协议:类路径,java,spring,Java,Spring,我试图在spring中使用schemalocation类路径从本地驱动器导入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.Ma

我试图在spring中使用schemalocation类路径从本地驱动器导入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.<init>(Unknown Source) ~[na:1.8.0_31]
    at java.net.URL.<init>(Unknown Source) ~[na:1.8.0_31]
    at java.net.URL.<init>(Unknown Source) ~[na:1.8.0_31]
15:10:19.336[localhost-startStop-1]调试o.s.b.f.xml.ResourceEntityResolver-无法根据系统根URL解析xml实体[classpath:spring-social-facebook-1.1.xsd]
java.net.MalformedURLException:未知协议:类路径
在java.net.URL.(未知来源)~[na:1.8.0\u 31]
在java.net.URL.(未知来源)~[na:1.8.0\u 31]
在java.net.URL.(未知来源)~[na:1.8.0\u 31]
这是我的applicationContext.xml的标题

<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:jdbc="http://www.springframework.org/schema/jdbc" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:beans="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:mongo="http://www.springframework.org/schema/data/mongo"     xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:social="http://www.springframework.org/schema/social"
    xmlns:facebook="http://www.springframework.org/schema/social/facebook"
    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/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社交网站jar,但没有使用包含xsd的spring社交facebook。我不再需要使用类路径了。谢谢。

你不应该在其他地方乱搞,而应该使用默认设置。对于Spring社交Facebook,您应该使用
http://www.springframework.org/schema/social/spring-social-facebook-1.1.xsd
或最好是无版本的
http://www.springframework.org/schema/social/spring-social-facebook.xsd

Spring总是首先从类路径从JAR加载xsd。Spring附带了一个定制的
EntityResolver
,它使用Spring jar文件的
META-INF
目录中不同的
Spring.schema
文件

获得类似错误的唯一原因是

  • 您还没有包括spring社交facebook所需的依赖项
  • 您包含了错误的spring社交facebook依赖项
  • 您使用的是不兼容的Spring和Spring社交版本
    我敢打赌,选项2不是所有1.1.0版本的spring社交facebook,而是混合版本的JAR。

    为什么你还要使用
    classpath:
    作为前缀。它应该是
    http://www.springframework.org/schema/social/spring-social-facebook-1.1.xsd
    而不是您现在拥有的。由于来自spring的自定义解析器,它将从类路径上的jar文件加载xsd(与所有其他xsd文件一样!)。实际上,spring社交facebook xsd已从该位置删除,这就是我尝试在本地创建xsd并使用它的原因。这不重要,因为默认情况下它是从包含的jar文件中解析的,就像spring中的其他xsd文件一样。如果这不起作用(我建议使用无版本模式),那么您要么在类路径上缺少JAR,要么使用了错误的版本(不是1.1),要么使用了不兼容的Spring和Spring Social版本。谢谢Deinum,您的评论帮助我解决了问题。