Closed jeffyding closed 7 years ago
I add application.properties into source folder, the content is:
spring.data.mongodb.database=test spring.data.mongodb.host=172.16.1.231 spring.data.mongodb.port=27017
That works now.
So this still works under spring-boot env, I want to use @Configuratin @EnableMongoRepositories, wish to see the demos...
If you're using plain Spring with Spring Data MongoDB, then the configuration is up to you. Spring Data MongoDB provides an abstract base class (AbstractMongoConfiguration
) that contains the essential bits to set up the necessary infrastructure.
Take a look at the reference documentation which contains some examples. Basically you need to provide an instance of Mongo
(MongoClient
for the 3.x driver) that contains endpoint details.
Hi: Follow the example, default mongo connection is localhost:27017, but I have standalone mongo server, so how can I modify the mongo db server connection info?
PS: I am using spring core not spring-boot, so I have to manually initailize mongo info, I am using Java config instead of xml config, could you help tell me how to use @EnableMongoRepositories, do you have some examples? appreciated! thanks!