Grails 应用程序中 Groovy 代码的编译
当我通过 grails war 为我的 Grails 应用程序构建一个 war 文件时,它仍然包含一些 groovy 文件。
当war文件部署到应用服务器上后,这些文件何时以及如何编译成java字节码?
When I build a war file for my Grails application via grails war
it still contains some groovy files.
After the war-filed is deployed on an application server, when and how are this files compiled to java bytecode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
模板用于动态脚手架。例如,如果您有这样的控制器
,那么它将使用模板在运行时创建控制器。这在实际应用程序中并不经常使用 - 它更多用于演示和入门 - 但它是一个选项。动态生成的控制器和 GSP 是根据模板创建并在内存中编译的。
groovy-all jar 确实有可以编译 Groovy 源代码的代码,但那是因为它是“-all”jar。仅仅因为它在那里并不意味着它一定被使用。一般来说,所有编译都是在构建战争时完成的,包括预编译 GSP。这是为了性能 - 您希望应用程序在生产中尽可能快。
The templates are there for dynamic scaffolding. For example if you have a controller like this
then it'll use the template to create a controller at runtime. This isn't very often used in real apps - it's more for demos and getting started - but it's an option. The dynamically generated controller and GSPs are created based on the templates and compiled in-memory.
The groovy-all jar does have code that can compile Groovy source, but that's because it's the "-all" jar. Just because it's there doesn't mean it's necessarily used. In general all compilation is done when building the war, including precompiling GSPs. This is for performance - you want the app to be as fast as possible in production.
在打包到 war 之前,groovy 文件会被编译成类文件。检查WEB-INF/classes目录
The groovy files are compiled into class files before you package into the war. Check the WEB-INF/classes directory