spring加载xml时联网下载dtd/schema怎么办?

spring xml 在验证XML时,可能会联网下载dtd, schema; 如果网络有问题,就会出错。

解决办法是:把远程的schema/dtd地址换成本地classpath路径。 比如

<!– Before –>

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"

"http://mybatis.org/dtd/mybatis-3-config.dtd">

<!– After –>

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"

"
classpath:org/apache/ibatis/builder/xml/mybatis-3-config.dtd">

参考:
https://groups.google.com/forum/?fromgroups=#!topic/mybatis-user/ssNHzaDWn-w

http://stackoverflow.com/questions/1729307/spring-schemalocation-fails-when-there-is-no-internet-connection

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.