List of usage examples for org.springframework.data.repository.init Jackson2ResourceReader readFrom
public Object readFrom(Resource resource, @Nullable ClassLoader classLoader) throws Exception
From source file:example.springdata.mongodb.util.BlogPostInitializer.java
@SuppressWarnings({ "unchecked", "rawtypes" }) private void loadFromClasspathSource(MongoOperations operations) throws Exception { Jackson2ResourceReader reader = new Jackson2ResourceReader(); Object source = reader.readFrom(new ClassPathResource("spring-blog.atom.json"), this.getClass().getClassLoader()); if (source instanceof Iterable) { ((Iterable) source).forEach(element -> operations.save(element)); } else {/*from w w w . jav a 2 s . c om*/ operations.save(source); } log.info("Imported blog posts from classpath!"); }