[英]java.net.MalformedURLException: unknown protocol: classpath
I am trying to import the xsd schema from local drive using schemalocation classpath in spring. 我试图在spring中使用schemalocation classpath从本地驱动器导入xsd架构。 I added the required file in the classpath and added the reference of this file with 我在类路径中添加了所需的文件,并添加了此文件的引用
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]
here is the header for my applicationContext.xml, 这是我的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">
I am using spring 4.1 with and spring-bean version 3.0. 我使用的是Spring 4.1和spring-bean 3.0版。
You shouldn't be messing around with other locations and use the defaults. 你不应该搞乱其他地方并使用默认值。 For Spring Social Facebook you should use http://www.springframework.org/schema/social/spring-social-facebook-1.1.xsd
or preferably the version less one http://www.springframework.org/schema/social/spring-social-facebook.xsd
. 对于Spring Social Facebook,您应该使用http://www.springframework.org/schema/social/spring-social-facebook-1.1.xsd
或者最好使用少一个版本http://www.springframework.org/schema/social/spring-social-facebook.xsd
。
Spring will always first load the xsd from the jars from the classpath. Spring将始终首先从类路径中加载jar中的xsd。 Spring ships with a custom EntityResolver
, the PluggableSchemaResolver
which uses the different spring.schemas
files in the META-INF
directory of Spring jar files. Spring附带了一个自定义的EntityResolver
,即PluggableSchemaResolver
,它使用Spring jar文件的META-INF
目录中的不同spring.schemas
文件。
The only reasons to get an error like you get (and why you try to work around it) is 获得错误的唯一原因(以及为什么要尝试解决它)是
I would bet on option 2 not having all the 1.1.0 versions of spring-social-facebook but mixing versions of jars. 我打赌选项2没有所有1.1.0版本的spring-social-facebook但混合版本的jar。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.