`

java web spring xsd 从 classpath加载

阅读更多

spring中的配置文件定义的 dtd,xsd等文件默认是从文件定义的地方加载校验的,比如下面是一个普通的spirng配置

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-4.1.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd">

 

spring启动的时候是要去连接网络的,这样有时候网络不好就会启动不了了,用类路径从本地加载就避免了问题。加载的文件是 xsd文件,这些文件在spring的jar包里, 类路径配置时可用jar包的路径,当然更方便的做法是把这些xsd文件拷贝到soruce目录下(source目录是classpath),这些xsd文件可以直接从网络下载。然后就有了下面的配置

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        classpath:spring-beans-4.1.xsd
        http://www.springframework.org/schema/context 
        classpath:spring-context-4.1.xsd
        http://www.springframework.org/schema/mvc
        classpath:spring-mvc-4.1.xsd
        http://www.springframework.org/schema/aop classpath:spring-aop-4.1.xsd
        http://www.springframework.org/schema/tx classpath:spring-tx-4.1.xsd">

 

 

 

分享到:
评论

相关推荐

    spring3.0 xsd文件

    spring3.0 xsd文件 spring3.0 xsd文件 spring3.0 xsd文件 spring3.0 xsd文件 spring3.0 xsd文件 spring3.0 xsd文件

    Spring加载XSD文件发生错误的解决方法

    主要介绍了Spring加载XSD文件发生错误的解决方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

    spring4.0xsd文件

    Spring默认在启动时是要加载XSD文件来验证xml文件的,所以如果有的时候断网了,或者一些开源软件...为了防止这种情况,Spring提供了一种机制,默认从本地加载XSD文件,这里分享几个xsd文件。初学者不用满大街跑的去找

    java生成xsd,xml示例

    java生成xsd,xml示例

    spring-beans-1.3.xsd

    spring-beans-4.3.xsd spring-beans-4.3.xsd spring-beans-4.3.xsd spring-beans-4.3.xsd

    spring5.0的全部xsd文件

    spring5.0的xsd文件,放在本地,免得eclipse从网上下载检测慢

    spring-context-3.2.xsd

    spring-context-3.2.xsd

    spring 4.25版本 xsd文件

    包含 spring-aop.xsd spring-beans.xsd spring-cache.xsd spring-jdbc spring-jms spring-lang 等

    J2EE web app 3.1 xsd

    J2EE web app 3.1 xsd

    spring-beans-4.2xsd 文件下载

    Spring默认在启动时是要加载XSD文件来验证xml文件的,所以如果有的时候断网了,或者一些开源软件切换域名,那么就很容易碰到应用启动不了。...为了防止这种情况,Spring提供了一种机制,默认从本地加载XSD文件

    spring配置文件的xsd约束文件

    内含spring-aop-4.0.xsd、spring-beans-4.0.xsd、spring-context-4.0.xsd、spring-mvc-4.0.xsd、spring-tool-4.0.xsd、spring-tx-4.0.xsd、spring-util-4.0.xsd,在xml中引入相应xsd文件,便可以自动提示

    spring-beans-3.0.xsd

    spring-beans-3.0.xsd

    xsd namexsd namexsd name

    java xsd java xsd java xsd java xsd java xsd java xsd

    Spring项目的xsd文件大全

    关于Springmvc,SpringBoot,SpringCould项目的xsd文件大全

    spring-context.xsd

    spring-context.xsd用于spring DI开发代码提示。用于Java开发。(包含2.5/3.1/3.2版本)

    xml生成xsd工具

    xml生成xsd 使用方法:java -jar trang.jar EchoRequest.xml EchoRequest.xsd

    根据xsd批量生成java类

    根据xsd批量生成java类,觉得很方便也很酷。但是有时候xsd生成的java类中含有汉字,结果总是有些问题。 可是xjc命令参数又没有encoding参数之类的。在网上搜了一通,忽然发现了一个好东东:xjc是由...

    spring-aop.xsd

    spring-aop.xsd用于spring aop开发代码提示。用于Java开发。(包含2.5/3.1/3.2版本)

Global site tag (gtag.js) - Google Analytics