yamlファイルをロードします。& Config.javaに格納します。ここで Yamlファイルの値がjavaのjacksonを使用してロードされていません
は私のYAMLファイルです(。そのはるかに大きく、私は与えている簡易版)ここで---
application:
admin:
jobInterValTime: 1440
customer: lc
system:
mongo:
host: localhost
port: 27017
dbName: LC_Test
collections:
groupsCollection: groups
membershipCollection: memberships
personsCollection: persons
がConfig.javaです:
public class Application {
private Admin admin;
//Getter Setter
}
public class Config {
private Application application;
private System system;
//Getter setter
}
Application.java
Admin.java
public class Admin {
private String jobInterValTime;
private String customer;
//Getter Setter
}
System.java
public class System {
private Mongo mongo;
//Getter Setter
}
Mongo.java
public class Mongo {
private String host;
private String port;
private String dbName;
private Map<String, String> collections;
//Getter Setter
}
しかしConfig.java
内部application
& system
オブジェクトがnull.No例外が起こって来ています。誰でも助けることができますか?
これは私が書いたものです。
Config config = null;
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
try{
config = objectMapper.readValue(new File("src/test/java/resources/test1.yaml"), Config.class);
//System.out.println(application.getAdmin().getCustomer());
// System.out.println(unidataConfig.getApplication().getAdmin().getCustomer());
} catch(Exception e) {
e.printStackTrace();
}