java - How to override the defaults provided by SPRING BOOT Autoconfiguration -


After

I have some knowledge of Spring 2.5 development and Java, but I know more about boot and data including modern spring. I'm trying to I am looking at the project:

I have been working on this example on my machine, but I want to override some aspects of the example. For example, I want to specify my own Mongo database server and name to use in the project. It seems that the thing to do is to specify a new bean Mongo data source to make, but I'm not sure how to do this in this case

  import com.mongodb.Mongo Import com.mongodb.MongoClient; Import example.person.Person; Import example.person.PersonRepository; Import example.treasure.Treasure; Import example.treasure.TreasureRepository; Import org.slf4j.Logger; Import org.slf4j.LoggerFactory; Import organization Source: Import org.springframework.boot.SpringApplication; Import org.springframework.boot.autoconfigure.EnableAutoConfiguration; Import org.springframework.boot.context.properties.ConfigurationProperties; Import org.springframework.context.annotation.Bean; Import org.springframework.context.annotation.configuration; Import org.springframework.data.jpa.repository.config.EnableJpaRepositories; Import organization Source: Import javax.activation.DataSource; Import javax.annotation.PostConstruct; import java.net.UnknownHostException; / ** * The application configuration file is used for bootstrap and data setup * * @author Greg Turnquash * @author Oliver Gyrk * / @Configuration @EnableAutoConfiguration @EnableJpaRepositories @EnableMongoRepositories Public class application {Personal Static Last logger log = LoggerFactory GetLogger (Application.class); Public static zero main (string [] args) {SpringApplication.run (application.class, args); } @ Autonomous person repository person repository; @ Autonomous Treasure Resizatory Treasury Reservatory; @PostConstruct void checkitOut () {personRepository.save (new person ("frado", "baggins")); Person repository.Seve (new person ("Bilbo", "Baggins")); (Person: personRepository.findAll ()) {log.info ("hello" + person. To string ()); } TreasureRepository.deleteAll (); TreasureRepository.save (new jackpot ("sting", "Made the Elves")); TreasureRepository.save (New Treasure ("The Ring of Sorrow", "A Ring to Rule Them")); (Treasure Treasure: treasureRepository.findAll ()) {log.info ("Found Treasure" + Treasure. Tothing ()); }}}    

"itemprop =" text ">

The actual properties were in the dock attached to me < P> There was no mistake in suggestion from Marcus -. It's spring.data.mongodb *

I'm still not sure how I can change the name of the db though - the default "appears to be test" - maybe it's a default in Moongbab ?

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -