Tomcat、Weblogic、Glassfish 的 Grails 3 JNDI 数据源 - 与 Grails 2
Grails 3 JNDI datasource for Tomcat, Weblogic, Glassfish - Vs Grails 2
我正在尝试从 Grails 2 迁移到 Grails 3。
在 Grails 2 中,我在 Production-env
的 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
我在 运行ning "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 运行-app 时工作正常,并且将 WAR 部署到 Tomcat.
也工作正常
有人可以帮助我将我的 "jndi expression" 从 Grails 2 移植到 Grails 3 中吗?
您似乎在尝试在 yml 文件中使用 groovy 语法,但这不起作用。如果您想使用 groovy 语法,您可以创建一个 application.groovy
文件(它将与 application.yml
文件合并)。
另请查看许多方法 spring-boot 允许您通过环境变量、属性、yml 等注入属性。http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
我正在尝试从 Grails 2 迁移到 Grails 3。
在 Grails 2 中,我在 Production-env
的 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
我在 运行ning "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 运行-app 时工作正常,并且将 WAR 部署到 Tomcat.
也工作正常有人可以帮助我将我的 "jndi expression" 从 Grails 2 移植到 Grails 3 中吗?
您似乎在尝试在 yml 文件中使用 groovy 语法,但这不起作用。如果您想使用 groovy 语法,您可以创建一个 application.groovy
文件(它将与 application.yml
文件合并)。
另请查看许多方法 spring-boot 允许您通过环境变量、属性、yml 等注入属性。http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html