我是grails的新手,我正在寻找一种从context.xml中为构建版本检索数据的方法。
我的开发环境配置看起来像这样。
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"]
}
}
我的context.xml看起来像这样
<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" />
我的backUpMailSession看起来就像这样
在我的构建环境中,我尝试使用
dataSource {
grails.mailSetup.jndiName = "java:comp/env/mailSetupSession"
grails.backUpMail.jndiName = "java:comp/env/backUpMailSession"
}
它不起作用。还有其他办法吗?或者我做错了还是缺少某些过程?
每次我调用grailsApplication.config.grails.mailSetup或grailsApplication.config.grails.backUpMail我得到的是[:]