与数据库连接时,如何在Java中将这些证书和密码一起添加
示例代码-
@Configuration
@PropertySource("classpath:DBConfig.properties")
public class SpringMongoConfig extends AbstractMongoConfiguration {
final static Logger logger = LogManager.getLogger(SpringMongoConfig.class);
@Autowired
Environment environment;
@Override
@Bean(name = "mongo-db-name")
public String getDatabaseName() {
return this.mongoClientURI().getDatabase();
}
@Override
@Bean
public MongoClient mongoClient() {
logger.info("IMP!! Creating instance of MongoClient");
return new MongoClient(this.mongoClientURI());
}
private MongoClientURI mongoClientURI() {
return new MongoClientURI(environment.getProperty("mongodb.url"));
//But unable to add the certificates needed to connect
}
}