简体   繁体   English

如何使用JAR文件中的MyBatis DTD?

[英]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. 事实证明,我们的环境存在问题,来自服务器的HTTP请求无法路由到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. 但是它突出了我们使用MyBatis的应用程序以及Spring和其他使用XML配置的库中的“缺陷”。 That is, the DTDs are located on servers out of our control... And, if they are not reachable: dead applications. 也就是说,DTD位于我们无法控制的服务器上……而且,如果无法访问它们,则为死应用程序。

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; 我们发现DTD位于实际的MyBatis JAR文件中……但是,我们如何更改XML文件以引用那些嵌入式DTD文件? 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. 我发现我们可以将DTD复制到XML所在的文件夹中并使其工作。 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. 我要列出的就是在MyBatis JAR包中找到DOCTYPE引用DTD的URL。 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">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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