简体   繁体   中英

How to use the MyBatis DTDs located in the JAR file?

We had a recent issue today where a number of our applications failed to restart after a power outage. Turns out we had an issue with our environment where HTTP requests from servers could not route out to the internet.

Regardless of the reason, the immediate problem is resolved. But it highlighted a "flaw" in our applications that use MyBatis, and Spring and other libraries that utilize XML configurations. That is, the DTDs are located on servers out of our control... And, if they are not reachable: dead applications.

We found the DTDs are located within the actual MyBatis JAR file... but, how do we change the XML files to reference those embedded DTD files; removing the system reliance on the availability of an external server?

Changing this, to what? <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >

I've found that we can copy the DTDs into the same folder as the XML and make it work. However, for the hundreds of places where these files are, that will be time consuming. The other thought is we simply host them on our own internal server(s), but again, if they go down then we are in trouble.

What I'd list to do is have the URL of the DOCTYPE reference the DTD located right in the packages MyBatis JAR file. Is it possible?

Try to use this one at the top :

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "org/apache/ibatis/builder/xml/mybatis-3-mapper.dtd">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM