报错
不联互联网网启动服务,报错如下:
org.xml.sax.SAXParseException; lineNumber: 13; columnNumber: 69; schema_reference.4: 无法读取方案文档 'https://www.springframework.org/schema/context/spring-beans.xsd', 原因为 1) 无法找到文档; 2) 无法读取文档; 3) 文档的根元素不是 <xsd:schema>。
xml约束如下:
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
错误原因:
需要联网下载 https://www.springframework.org/schema/context/spring-beans.xsd 文件,当不能联网,或者网络特别慢时,就会报错
如果网络正常,会先下载该文件,由于该文件在国外服务器上,所以下载缓慢,导致启动服务慢
解决方法
其实该文件已经存在在本地jar包中,让spring到本地中找即可
将上面的 https 改成 http,就不在联网下载文件,而是到本地中找
完整约束
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
感谢:
https://blog.csdn.net/qq_38647878/article/details/91824859