BAEL-2841 updated code to use multiple xml files

This commit is contained in:
sumit.sg34 2019-04-17 18:52:51 +05:30
parent 93d6d243ac
commit 029ab027ed
3 changed files with 13 additions and 4 deletions

View File

@ -22,11 +22,13 @@ public class JpaPopulators {
@Bean @Bean
public UnmarshallerRepositoryPopulatorFactoryBean repositoryPopulator() { public UnmarshallerRepositoryPopulatorFactoryBean repositoryPopulator() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setClassesToBeBound(Fruit.class); Jaxb2Marshaller unmarshaller = new Jaxb2Marshaller();
unmarshaller.setClassesToBeBound(Fruit.class);
UnmarshallerRepositoryPopulatorFactoryBean factory = new UnmarshallerRepositoryPopulatorFactoryBean(); UnmarshallerRepositoryPopulatorFactoryBean factory = new UnmarshallerRepositoryPopulatorFactoryBean();
factory.setUnmarshaller(marshaller); factory.setUnmarshaller(unmarshaller);
factory.setResources(new Resource[] { new ClassPathResource("fruit-data.xml") }); factory.setResources(new Resource[] { new ClassPathResource("apple-fruit-data.xml"), new ClassPathResource("guava-fruit-data.xml") });
return factory; return factory;
} }

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<fruit>
<id>2</id>
<name>guava</name>
<color>green</color>
</fruit>