Grails 2.1.0 Not Auto-Reloading / Auto-Recompiling

前端 未结 4 1786
天涯浪人
天涯浪人 2021-02-15 23:24

Seems that Grails does automatically recompile my GSP pages, but not my controllers. It used to work with the previous version of Grails. Any idea what I can look for?

U

相关标签:
4条回答
  • 2021-02-15 23:52

    Disclaimer: Auto-reload has always worked for me on my Mac.

    I've found a couple of things that might be useful.

    First, it appears that running a custom environment (that isn't dev) disables auto-reload (see this stackoverflow post), so you'll want to follow the directions in that post if you're running the application that way.

    Second, if you're running the app as a war, for sure auto-reload is turned off. (See the Grails Auto-Reload Page)

    Third, I've found that using a Grails IDE (such as IntelliJ or SpringSource) really adds a lot of stability to the Grails development environment. For example, IntelliJ doesn't use the Grails shell file that comes with the binary download. It manually invokes the Grails jars and bootstraps.

    My questions to you are:

    What does the rest of your environment look like? How are you running your application (run-app or another container)?

    What Grails plugins do you have installed (the Grails documentation says the tomcat plugin is configured for optimal auto-reloading)?

    Do you have any other Grails binaries downloaded on your computer (could cause confusion when it's trying to load)?

    And finally, are you able to reproduce this issue in a clean environment (meaning new Grails binary, fresh Grails create-app)?

    I'd also recommend reading the Deployment section of the Grails documentation (found here). It has some pertinent information regarding the reloading.

    I apologize for the longwinded and potentially non-answering answer, but I hope this has sparked an idea or two. Let me know how things turn out!

    0 讨论(0)
  • 2021-02-16 00:09

    I had this problem when I had a BaseController class from which other controllers were derived. If I make changes to BaseController class such as adding a method or closure, change a method name, import some classes etc, the whole class reloading feature in Grails will come to a grinding halt.

    The only solution that worked for me was to delete the target directory into which all classes were compiled. At least that way I did not have to restart the server every time which saved me from having to wait about 30 seconds to display the start page. It could be pretty annoying when class reloading feature does not work as expected.

    Grails auto-reloading feature is not without quirks. Some of these quirks are ultimately related to java and how class loading works in servlet container environment. I hope the Grails team will make it a priority to provide seamless class reloading for Grails like other scripting environments( ruby, PHP, python or play framework) because some other aspects of this framework is such a pleasure to deal with.

    0 讨论(0)
  • 2021-02-16 00:12

    Strange, I've never had a problem with this. Are you sure that your controllers are compiling correctly, no typos? I've found that it generally only takes a second or two to see a change reflected in the controllers. Domain object changes require a restart (they usually wipe your saved data) and I've found that sometimes a change to a spring managed resource (like an injected service) dont' take. But controllers and GSP pages recompile 97% of the time :)

    I go between GGTS (eclipse) and the command line run-app and it almost always works for me. Are you doing any sort of caching perhaps? I'm running JDK 1.6 on Lion, grails 2.1.1

    Usually you will see output telling you that a file has recompiled within a second or two of hitting save.

    0 讨论(0)
  • 2021-02-16 00:13

    If you name the package names on your controllers incorrectly (as in the folder structure does not agree with the package declaration), the application will still run and no errors will be reported, but auto-reloading will not work.

    0 讨论(0)
提交回复
热议问题