mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Use non-deprecated API to create Mongo client
This commit is contained in:
parent
63fefbd7e7
commit
a592215651
@ -35,7 +35,8 @@ import org.springframework.data.mongodb.repository.config.EnableMongoRepositorie
|
||||
|
||||
import com.mongodb.DBPort;
|
||||
import com.mongodb.Mongo;
|
||||
import com.mongodb.MongoURI;
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.MongoClientURI;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's Mongo
|
||||
@ -95,13 +96,13 @@ public class MongoRepositoriesAutoConfiguration {
|
||||
}
|
||||
|
||||
public String database() {
|
||||
return this.database == null ? new MongoURI(this.uri).getDatabase()
|
||||
return this.database == null ? new MongoClientURI(this.uri).getDatabase()
|
||||
: this.database;
|
||||
}
|
||||
|
||||
public Mongo mongo() throws UnknownHostException {
|
||||
return this.host != null ? new Mongo(this.host, this.port) : new Mongo(
|
||||
new MongoURI(this.uri));
|
||||
return this.host != null ? new MongoClient(this.host, this.port)
|
||||
: new MongoClient(new MongoClientURI(this.uri));
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
|
Loading…
Reference in New Issue
Block a user