【发布时间】:2016-11-16 23:20:15
【问题描述】:
我正在尝试从 Grails 2 迁移到 Grails 3。
在 Grails 2 中,我在生产环境中的 datasource.groovy 文件中将其用作我的 JNDI 名称
jndiName = "${(System.getProperty('catalina.home') && (System.getProperty('java.class.path')).trim().toLowerCase().indexOf('tomcat') > 0 ) ? 'java:comp/env/' : ''}jdbc/myGrails"
我发现 Glassfish、Weblogic 和 Tomcat 对我来说效果很好。
但是,当我在 Grails 3 中尝试此操作时,在 application.yml 中:
jndiName: ${(System.getProperty('catalina.home') && (System.getProperty('java.class.path')).trim().toLowerCase().indexOf('tomcat') > 0 ) ? 'java:comp/env/' : ''}jdbc/myGrails
运行“grails run-app”时出现此错误:
| Error Error occurred running Grails CLI: mapping values are not allowed here
in 'reader', line 123, column 169:
... mcat') > 0 ) ? 'java:comp/env/' : ''}jdbc/traxGrails
^
(Use --stacktrace to see the full trace)
如果我在 Grails 3 中使用它:
jndiName: java:/comp/env/jdbc/myGrails
然后在使用 Grails run-app 时它可以正常工作,并且在将 WAR 部署到 Tomcat 时也可以正常工作。
有人可以帮助我从 Grails 2 中获取我的“jndi 表达式”以在 Grails 3 中工作吗?
【问题讨论】: