Можно ли внедрить файл ниже yaml в приложение Spring Boot как Map<String, Map<String, String>
, где tradeType
будет ключом внешней карты, а P и B будут ключевым значением для внутренней карты для.
tradeType:
P: B
S: S
securityCode:
ICI: ICICI Bank
BOB: Bank of Baroda
BOA: Bank of America
BOS: Bank of Singapore
Как и предполагалось, так выглядит мой класс.
@Configuration
@PropertySource("file:data/referenceDataMapping.yaml")
@ConfigurationProperties(prefix = "map")
public class ReferenceDataMapping {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private Map<String, Map<String, String>> entries;
@Override
public String toString() {
if (entries != null) {
logger.info(entries.toString());
return entries.toString();
} else {
return null;
}
}
public Map<String, Map<String, String>> getEntries() {
return entries;
}
public void setEntries(Map<String, Map<String, String>> entries) {
this.entries = entries;
}
}
от build.gradle
dependencies {
compile 'org.springframework.boot:spring-boot-starter-activemq:2.1.2.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-security:2.1.2.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-web:2.1.2.RELEASE'
compile 'org.apache.camel:camel-spring-boot-starter:2.23.1'
compile 'org.apache.camel:camel-quartz2:2.23.1'
compile 'org.apache.camel:camel-jms:2.23.1'
compile 'org.apache.camel:camel-jacksonxml:2.23.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
compile 'net.sf.saxon:Saxon-HE:9.9.1-1'
testCompile 'org.springframework.boot:spring-boot-starter-test:2.1.2.RELEASE'
testCompile 'org.springframework.security:spring-security-test:5.1.3.RELEASE'
}
referenceDataMapping.yaml
map:
entries:
tradeType:
P: B
S: S
securityCode:
ICI: ICICI Bank
BOB: Bank of Baroda
BOA: Bank of America
BOS: Bank of Singapore