【01】Eclipse中配置spring的xsd 便于从本地加载而非网络

spring xsd

1.spring的xsd在Eclipse中的配置

1.1xsi:schemaLocation

		http://www.springframework.org/schema/beans 
		http://www.springframework.org/schema/beans/spring-beans.xsd 
		http://www.springframework.org/schema/mvc 
		http://www.springframework.org/schema/mvc/spring-mvc.xsd 
		http://www.springframework.org/schema/context 
		http://www.springframework.org/schema/context/spring-context.xsd
		http://www.springframework.org/schema/aop 
		http://www.springframework.org/schema/aop/spring-aop.xsd 
		http://www.springframework.org/schema/tx 
		http://www.springframework.org/schema/tx/spring-tx.xsd 

1.2Eclipse中设置的key名

(1)此key名称,指向的是本地spring的xsd文件。
(2)在我的项目中,是将spring4.2.6的所有xsd文件放在了项目的
webapp/WEB-INF/spring_4_2_6_schema
文件中。
(3)这些xsd文件来源于spring4.2.6的源码库,即下次只需要下载一个Spring4.2.6的源码库文件下来,就可以在Eclipse中配置从本地文件系统中或工作空间中加载xsd文件。我的项目采用的是从工作空间中加载xsd文件

1.3在本地文件系统中选择xsd文件进行配置

在这里插入图片描述

1.4在workspace工作空间中选择xsd文件进行配置

在这里插入图片描述

2.重点

2.1Key的配置

上面两种配置方式中,指向xsd文件的key一定要修改一下,不要用默认的路径,要在路径的尾巴上把该xsd文件的文件全名给加上,如下总结了所有的key名称。加上全名儿,是让eclipse知道不要从网络上去加载xsd文件了,只要加载我本地的就可以了。


    http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
    http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
    http://www.springframework.org/schema/cache/spring-cache-4.2.xsd
    http://www.springframework.org/schema/context/spring-context-4.2.xsd
    http://www.springframework.org/schema/jdbc/spring-jdbc-4.2.xsd
    http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
    http://www.springframework.org/schema/jms/spring-jms-4.2.xsd
    http://www.springframework.org/schema/lang/spring-lang-4.2.xsd
    http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
    http://www.springframework.org/schema/oxm/spring-oxm-4.2.xsd
    http://www.springframework.org/schema/task/spring-task-4.2.xsd
    http://www.springframework.org/schema/tool/spring-tool-4.2.xsd
    http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
    http://www.springframework.org/schema/util/spring-util-4.2.xsd
    http://www.springframework.org/schema/websocket/spring-websocket-4.2.xsd

2.2spring配置文件中xml的xsi:schemaLocation的配置变更

意思是要把spring的配置文件,比如springmvc.xml,service.xml,dao.xml中的xsi:schemaLocation统一变更一下,变更为上面配置的key,如下图所示:
在这里插入图片描述

2.3具体代码

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" 
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
		http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
		http://www.springframework.org/schema/mvc 
		http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd 
		http://www.springframework.org/schema/context 
		http://www.springframework.org/schema/context/spring-context-4.2.xsd
		http://www.springframework.org/schema/aop 
		http://www.springframework.org/schema/aop/spring-aop-4.2.xsd 
		http://www.springframework.org/schema/tx 
		http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">

3.尽情享受代码编写时的提示信息吧

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值