---
title: "断网运行jar包加载spring文件时，提示cvc-elt.1: Cannot find the declaration of element 'beans'."
author: "ttling"
date: "2015-01-21T22:27:24Z"
tags: []
slug: "jar-spring-cvc-elt-1-cannot-find-the-declaration-of-element-beans"
draft: false
lastmod: "2015-01-21T22:29:38Z"
id: 2178251
url: "https://ttling.iteye.com/blog/2178251"
---

头疼的spring加载问题：

断网运行jar包加载spring文件时，提示cvc-elt.1: Cannot find the declaration of element 'beans'.

在网上搜索N种方法，最后发现适合我自己程序的是该方法：
**替换文件头部**
**<u>源文件头部</u>**

```java
<?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:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
```


**<u>替换后</u>**

```java
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN/EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
```



当然网上嗨有其他方法可以使用的方法，但是觉得不是好的办法
将spring的目录org放到本地web服务的根目录中，使用本地IP访问，如：

```java
<?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:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://192.168.11.23/org/springframework/beans/factory/xml/spring-beans-3.0.xsd">
```