|
@@ -3,10 +3,10 @@ package cn.com.qmth.examcloud.core.questions.starter.mongo;
|
|
import com.mongodb.MongoClient;
|
|
import com.mongodb.MongoClient;
|
|
import com.mongodb.client.MongoCollection;
|
|
import com.mongodb.client.MongoCollection;
|
|
import com.mongodb.client.MongoDatabase;
|
|
import com.mongodb.client.MongoDatabase;
|
|
-
|
|
|
|
import org.bson.Document;
|
|
import org.bson.Document;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
|
@@ -15,18 +15,18 @@ import org.springframework.context.annotation.Configuration;
|
|
*/
|
|
*/
|
|
@Configuration
|
|
@Configuration
|
|
public class NativeMongoConfig {
|
|
public class NativeMongoConfig {
|
|
-
|
|
|
|
- private static final String DB_NAME = "comm-ques-bank";
|
|
|
|
-
|
|
|
|
private static final String PDU_COLLECTION_NAME = "paperDetailUnit";
|
|
private static final String PDU_COLLECTION_NAME = "paperDetailUnit";
|
|
|
|
|
|
|
|
+ @Value("${mguri.database}")
|
|
|
|
+ private String dbName;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private MongoClient mongoClient;
|
|
private MongoClient mongoClient;
|
|
|
|
|
|
@Bean
|
|
@Bean
|
|
@Qualifier("mongoDatabase")
|
|
@Qualifier("mongoDatabase")
|
|
MongoDatabase getMongoDatabase() {
|
|
MongoDatabase getMongoDatabase() {
|
|
- return mongoClient.getDatabase(DB_NAME);
|
|
|
|
|
|
+ return mongoClient.getDatabase(dbName);
|
|
}
|
|
}
|
|
|
|
|
|
@Bean
|
|
@Bean
|
|
@@ -35,4 +35,5 @@ public class NativeMongoConfig {
|
|
MongoDatabase database = getMongoDatabase();
|
|
MongoDatabase database = getMongoDatabase();
|
|
return database.getCollection(PDU_COLLECTION_NAME);
|
|
return database.getCollection(PDU_COLLECTION_NAME);
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+
|
|
|
|
+}
|