1
我如何配置application.properties使用多個mongoTemplate春季啓動蒙戈多個數據庫
我目前的配置。
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=user
我的代碼:
public class UserRepository
{
@Autowired
private MongoTemplate mongoTemplate;
public UserInfo getUserInfo(){
//i can get user information from user database
mongoTemplate.findAll();
}
}
我想從其他數據庫中的數據,如常見的數據庫。例如
public class UserRepository
{
@Autowired
private MongoTemplate mongoUserTemplate;
@Autowired
private MongoTemplate mongoCommonTemplate;
public UserInfo getUserInfo(){
//i can get user information from user database
mongoUserTemplate.findAll();
//how can i configure application.properties to use
//mongoCommonTemplate...
mongoCommonTemplate.findAll();
}
}