我在 .xml 文件中有与数据库连接相关的属性。我想在 .properties 文件中使用相同的值。是否可以从 .xml 文件中获取值并设置为 .properties?
- 谢谢
使用loadFromXML时出现异常
线程“主”java.util.InvalidPropertiesFormatException 中的异常:org.xml.sax.SAXException:无效的系统标识符:http ://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd at java.util.XMLUtils。 load(XMLUtils.java:76) at java.util.Properties.loadFromXML(Properties.java:868) at com.generalsentiment.test.quartz.CronTriggerExample.run(CronTriggerExample.java:40) at com.generalsentiment.test.quartz .CronTriggerExample.main(CronTriggerExample.java:117) 原因:org.xml.sax.SAXException:无效的系统标识符:http ://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd 在 java.util.XMLUtils$Resolver.resolveEntity(XMLUtils.java:190) 在 org.apache.xerces.util.EntityResolverWrapper.resolveEntity(Unknown Source) 在 org.apache.xerces.impl.XMLEntityManager.resolveEntity(Unknown Source) 在org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at org. apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) at java.util.XMLUtils.getLoadingDoc(XMLUtils.java:102) at java.util.XMLUtils.load(XMLUtils.java:74) ... 还有 3 个 Java 结果:1