我的 java 项目中有这个 sonarqube 问题:Disable access to external entity in XML parsing。我已经实现了这样的兼容解决方案:
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
但是现在当我调试代码时,我遇到了这个异常:
java.lang.IllegalArgumentException: Not supported: http://javax.xml.XMLConstants/property/accessExternalDTD
我究竟做错了什么?