January 2018
Intermediate to advanced
414 pages
10h 29m
English
We can modify our DatabaseInitializer class to add some initial data to our database using the repository that we just created:
package com.microservices.chapter5import org.springframework.beans.factory.annotation.Autowiredimport org.springframework.data.mongodb.core.ReactiveMongoOperationsimport org.springframework.stereotype.Componentimport javax.annotation.PostConstruct@Componentclass DatabaseInitializer { @Autowired lateinit var customerRepository: CustomerRepository @Autowired lateinit var mongoOperations: ReactiveMongoOperations @PostConstruct fun initData() { mongoOperations.collectionExists("Customers").subscribe { if (it != true) mongoOperations.createCollection("Customers").subscribe { println("Customers collections ...
Read now
Unlock full access