简体   繁体   中英

Compilation of Groovy Code in Grails application

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?

The templates are there for dynamic scaffolding. For example if you have a controller like this

class PersonController {
   static scaffold = Person
}

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.

The groovy files are compiled into class files before you package into the war. Check the WEB-INF/classes directory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM