Example usage for org.springframework.data.repository.init Jackson2RepositoryPopulatorFactoryBean setMapper

List of usage examples for org.springframework.data.repository.init Jackson2RepositoryPopulatorFactoryBean setMapper

Introduction

In this page you can find the example usage for org.springframework.data.repository.init Jackson2RepositoryPopulatorFactoryBean setMapper.

Prototype

public void setMapper(@Nullable ObjectMapper mapper) 

Source Link

Document

Configures the ObjectMapper to be used.

Usage

From source file:example.springdata.mongodb.geojson.Application.java

/**
 * Read JSON data from disk and insert those stores.
 * //from ww  w  .  j a va  2 s .  com
 * @return
 */
public @Bean AbstractRepositoryPopulatorFactoryBean repositoryPopulator() {

    ObjectMapper mapper = new ObjectMapper();
    mapper.addMixIn(GeoJsonPoint.class, GeoJsonPointMixin.class);
    mapper.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);

    Jackson2RepositoryPopulatorFactoryBean factoryBean = new Jackson2RepositoryPopulatorFactoryBean();
    factoryBean.setResources(new Resource[] { new ClassPathResource("starbucks-in-nyc.json") });
    factoryBean.setMapper(mapper);

    return factoryBean;
}