Reputation: 8936
We can use AbstractMongoConfiguration (http://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/config/AbstractMongoConfiguration.html) to do the mongodb configuration. Also, we can use application.properties to do config (http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html). Which one is better?
Upvotes: 2
Views: 2359
Reputation: 17045
This is definitely an opinion-based question and answer.
The answer is simple: My opinion is that spring-boot really encourages you to use application.properties whenever possible. So, I'd says:
it is better to use application.properties with spring-boot, rather than java config
spring-boot's AutoConfiguration happens so early in the spring lifecycle, that it is nearly impossible not to use application.properties (to allow AutoConfigurations to load their properties).
Also, spring-cloud-config allows loading properties remotely, so that would be another possible future advantage of using this mechanism.
Upvotes: 0