grails config get data from context.xml

左心房为你撑大大i 提交于 2020-01-05 09:09:30

问题


im new to grails and im looking for a way to retrieve data from context.xml for the build version.

my development environment config looks like this.

    grails {
        mail {
            host     = "smtp.gmail.com"
            port     = 25
            username = "username@mail.com"
            password = 'password'

            props = ["mail.smtp.auth":"true",
                    "mail.smtp.socketFactory.port":"25",
                    "mail.debug":"false",
                    "mail.smtp.from":"username@mail.com",
                    "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
                    "mail.smtp.socketFactory.fallback":"false"]
        }

        backUpMail {
            host     = "smtp.gmail.com"
            port     = 465
            username = "username2@mail.com"
            password = 'p@ssword'

            props = ["mail.smtp.auth":"true",
                    "mail.smtp.socketFactory.port":"465",
                    "mail.debug":"false",
                    "mail.smtp.from":"username2@mail.com",
                    "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
                    "mail.smtp.socketFactory.fallback":"false"]
        }
    }

my context.xml looks like this

 <Resource name="mailSetupSession"
    auth="Container"
    type="java.lang.String"
    host="smtp.gmail.com"
    port="25"
    username="username@mail.com"
    password="p@ssword"
    props.mail.smtp.auth="true"
    props.mail.smtp.socketFactory.port="25"
    props.mail.debug="false"
    props.mail.smtp.from="username@mail.com"
   props.mail.smtp.socketFactory.class="javax.net.ssl.SSLSocketFactory"
    props.mail.smtp.socketFactory.fallback="false" />

my backUpMailSession looks just like this

in my build environment i tried using

    dataSource {
       grails.mailSetup.jndiName = "java:comp/env/mailSetupSession"
       grails.backUpMail.jndiName = "java:comp/env/backUpMailSession"
    }

its not working. is there any other way to do this? or am i doing it wrong or lacking some process?

every time I call grailsApplication.config.grails.mailSetup or grailsApplication.config.grails.backUpMail all i get is [:]

来源:https://stackoverflow.com/questions/49609097/grails-config-get-data-from-context-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!