永发信息网

怎么获取springboot配置的连接池对象

答案:2  悬赏:0  手机版
解决时间 2021-03-02 16:35
  • 提问者网友:川水往事
  • 2021-03-02 10:30
怎么获取springboot配置的连接池对象
最佳答案
  • 五星知识达人网友:青尢
  • 2021-03-02 10:38
怎么获取springboot配置的连接池对象
使用应用服务器的连接池,效率较高,而且不需要在代码中出现数据库信息。 使用spring管理连接池的话,与服务器无关,便于移植。
全部回答
  • 1楼网友:旧脸谱
  • 2021-03-02 10:45
public mongoclient createmongoclient(mongoclientoptions options) throws unknownhostexception { try { if (hascustomaddress() || hascustomcredentials()) { if (options == null) { options = mongoclientoptions.builder().build(); } list credentials = null; if (hascustomcredentials()) { string database = this.authenticationdatabase == null ? getmongoclientdatabase() : this.authenticationdatabase; credentials = arrays.aslist(mongocredential.createmongocrcredential( this.username, database, this.password)); } string host = this.host == null ? "localhost" : this.host; int port = this.port == null ? default_port : this.port; return new mongoclient(arrays.aslist(new serveraddress(host, port)), credentials, options); } // the options and credentials are in the uri return new mongoclient(new mongoclienturi(this.uri, builder(options))); } finally { clearpassword(); } }
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯