Grails automatically reloads new controller actions

I have

  • created a new project Grails 2.4.3
  • created by TestController
  • set grails.reload.enabled = true to BuildConfig.groovy
  • run application with grails -reloading run-app

My controller action code:

 def index() { render "test" } 

When I change the line test to test2 - I see on the console (in Eclipse):

 .................. |Compiling 1 source files 

And after reloading the page, I see test2 - ok.

But when I try to add a new method:

 def test3() { render "test3" } 

I see:

error result

Why? Why not even a URL?

Example - action does not exist: enter image description here

The interesting thing is when I create a new controller, the index action of the new created controller works ...

EDIT

After some time, I decided to go with spring-boot and, in fact, it does not work there either. I think springloaded is a problem here because it does not raise the added new method in @Controller

+6
source share
3 answers

I asked the same question in github repo .

It seems that the latest spring-loaded SNAPSHOT works just fine .

But it should be integrated into Grails - perhaps in the next release unfortunately :(

+4
source

I took responsibility to report this issue to Grails .

+1
source

Solution that works for me:

1) Versions:

  • IDE: Intellij IDEA 14.1.3
  • JDK: jdk1.7.0_25
  • GRAILS: 2.5.0

2) At BuildConfig.groovy:

 grails.reload.enabled = true grails.project.fork = [ test: false, run: false, ] 

3) My code was originally compiled on grails 2.4.4, so I upgraded to 2.5.0. I had no problem changing the version using plugins or anything else. I assume this works because it uses later versions of spring -loaded. Steps:

  • set-grails version 2.5.0
  • clean
  • delete the work with the directory (to be sure, I really don't know how good this is).
  • compile and / or go to number 4

4) Debug Idea with this configuration: run-app -reloading


It works fine, debugging is not unlocked, rebooting is enabled, there is no console error after rebooting and all breakpoints work even after changing the code!

+1
source

Source: https://habr.com/ru/post/974204/


All Articles