[Commons Configuration] Comment utiliser SubsetConfiguration ?
Bonjour,
Mon code :
----------
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
package com.test.configuration;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.configuration.SubsetConfiguration;
public class testCommonsConfig001 {
public static void main(String[] args) {
BaseConfiguration config = new BaseConfiguration();
config.addProperty("prefix1.car01", 11.1);
config.addProperty("prefix1.car02", 22.2);
config.addProperty("prefix1.car03", 33.3);
config.addProperty("prefix2.car01", 11.1);
config.addProperty("prefix2.car02", 22.2);
config.addProperty("prefix2.car03", 33.3);
System.out.println(config.getDouble("prefix1.car01"));
System.out.println(config.getDouble("prefix1.car02"));
System.out.println(config.getDouble("prefix1.car03"));
SubsetConfiguration subsetPre01 = new SubsetConfiguration(config,
"prefix1");
System.out.println(subsetPre01.getDouble("car01"));
}
} |
J'obtiens ce message d'erreur :
---------------------------
Citation:
Exception in thread "main" java.util.NoSuchElementException: 'car01' doesn't map to an existing object
at org.apache.commons.configuration.AbstractConfiguration.getDouble(AbstractConfiguration.java:734)
at com.test.configuration.testCommonsConfig001.main(testCommonsConfig001.java:30)
Pourquoi car01 n'existe-t-il pas ?
Merci,