问题
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