我正在尝试连接到mlab
上托管的外部数据库。
在家里,效果很好。
但是在我的办公室里,由于我们在公司代理的背后,所以我的mlab实例未知。
com.mongodb.MongoSocketException: jhskdf234.mlab.com
at com.mongodb.ServerAddress.getSocketAddress(ServerAddress.java:188) ~[mongodb-driver-core-3.8.2.jar:na]
at com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:64) ~[mongodb-driver-core-3.8.2.jar:na]
at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:62) ~[mongodb-driver-core-3.8.2.jar:na]
at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:126) ~[mongodb-driver-core-3.8.2.jar:na]
at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117) ~[mongodb-driver-core-3.8.2.jar:na]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
Caused by: java.net.UnknownHostException: jhskdf234.mlab.com
at java.base/java.net.InetAddress$CachedAddresses.get(InetAddress.java:797) ~[na:na]
at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1505) ~[na:na]
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1364) ~[na:na]
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1298) ~[na:na]
at java.base/java.net.InetAddress.getByName(InetAddress.java:1248) ~[na:na]
at com.mongodb.ServerAddress.getSocketAddress(ServerAddress.java:186) ~[mongodb-driver-core-3.8.2.jar:na]
... 5 common frames omitted
这是我的配置:
spring:
data:
mongodb:
host: jhskdf234.mlab.com
port: 51507
username: admin
password: nimda2019
database: foodb
我尝试使用以下选项运行Spring应用程序,但结果相同:
-Dhttp.proxyHost=proxy.mycorporate.com
-Dhttp.proxyPort=3128
-Dhttp.proxyUser=myuser
-Dhttp.proxyPassword=mypwd
如何在公司代理后面使用外部mongodb库?