0
我正在測試Grail 3應用程序來連接運行在另一臺服務器上的mogoDB。Grails 3 MongoDB沒有從application.yml讀取connectionString
獨立java程序成功連接數據庫。但是Grail 3應用程序無法連接到數據庫。異常顯示其連接到本地主機。
我想了解爲什麼它沒有從aplication.yml文件中讀取連接字符串。
application.yml文件:
environments:
development:
grails:
mongodb:
connectionString: "mongodb://192.168.1.13:27017/test"
當我訪問該網頁,看到此錯誤消息
。
grails> 2017-02-14 22:52:28.116 ERROR --- [nio-8080-exec-9] o.g.web.errors.GrailsExceptionResolver : MongoTimeoutException occurred when processing request: [GET] /book/index
Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=127.0.0.1:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}]. Stacktrace follows:
爲什麼它連接到localhost?
嘗試從這個答案沒有工作。
Installing and using MongoDB in Grails 3.x
感謝
感謝它現在的作品。我正在使用Grails 3.2.5 – sfgroups