【问题标题】:Does anyone know how to connect grails app to mongoDB cloud database?有谁知道如何将 grails 应用程序连接到 mongoDB 云数据库?
【发布时间】:2021-06-22 19:49:27
【问题描述】:

我在 MongoDB atlas 中创建了一个数据库,我想创建一个连接到该数据库的 Grails 应用程序,但我不知道该怎么做。这是我在“application.yml”文件中尝试的,但它不起作用。

environments:
    development:
        grails:
            mongodb:
                host: "clustertpt.nfycx.mongodb.net"
                port: 27017
                username: "x"
                password: "x"
                databaseName: "tpt"
    production:
        grails:
            mongodb:
                host: "clustertpt.nfycx.mongodb.net"
                port: 27017
                username: "x"
                password: "x"
                databaseName: "tpt

谢谢

【问题讨论】:

    标签: mongodb grails mongodb-atlas


    【解决方案1】:

    我试过这个方法,效果很好!

    environments:
            development:
                grails:
                    mongodb:
                        url: "mongodb+srv://x:x@clustertpt.nfycx.mongodb.net/tpt?retryWrites=true&w=majority"
            test:
                development:
                    grails:
                        mongodb:
                            url: "mongodb+srv://x:x@clustertpt.nfycx.mongodb.net/tpt?retryWrites=true&w=majority"
            production:
                development:
                    grails:
                        mongodb:
                            url: "mongodb+srv://x:x@clustertpt.nfycx.mongodb.net/tpt?retryWrites=true&w=majority"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-23
      • 1970-01-01
      • 2019-04-30
      • 2021-12-16
      • 2022-08-15
      • 2020-05-23
      • 2020-05-16
      相关资源
      最近更新 更多