我正在努力将我的代码库从Commons Configuration 1.x迁移到2.x.但是,在版本2中,我收到一个错误,指示我在1.x中使用的密钥无效:
org.apache.commons.configuration2.ex.ConfigurationRuntimeException: Passed in key must select exactly one node (found 0): ios.invitation
我XMLConfiguration
的字符串转储如下所示:
ios/invitation/@config-class=com.example.email.DefaultEventEmailFormatter
ios/invitation/@fileName=request-cancel
ios/invitation/@subject=Itty-Bitty Skedi | Invitation
ios/invitation/@name=Invitation
ios/invitation/@senderFirstName=Itty-Bitty
ios/invitation/@shortDescription=You have a new notification waiting for you in the Skedi app.
ios/invitation/@fromEmailAddress=donotreply@example.com
ios/invitation/@contentType=text/plain
ios/invitation/@senderLastName=Skedi
XML文件是:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<ios>
<invitation
config-class=“com.example.email.DefaultEventEmailFormatter”
contentType="text/plain"
fromEmailAddress=“donotreply@example.com”
senderFirstName="Itty-Bitty"
senderLastName="Skedi"
subject="Itty-Bitty Skedi | Invitation"
shortDescription="You have a new notification waiting for you in the Skedi app."
name="Invitation"
fileName="request-cancel"/>
</ios>
</config>
Java代码段:
XMLConfiguration xmlConfig = builder.getConfiguration();
log.info(ConfigurationUtils.toString(xmlConfig));
BeanDeclaration decl = new XMLBeanDeclaration(xmlConfig, “ios.invitation”);//where `ios.invitation` is the key
有人可以帮我解决这个问题吗?
感谢您的时间!