I am a beginner trying to learn Grails 3.1. Regarding to the default, I add the following scratch on the index page:
<ul>
<g:each var="c" in="${grailsApplication.controllerClasses.sort { it.fullName } }">
<li class="controller">
<g:link controller="${c.logicalPropertyName}">${c.fullName}</g:link>
</li>
</g:each>
</ul>
At the beginning, the index page shows no controller. Then, I create another controller, TodosController for instance. Because this controller name is not nice somehow, so I want to rename it (of course, using refactory feature in Intellij IDEA) into TodoListController. Unfortunately, the code still remains two controllers and shows them in the index page. When I click on the link of TodosController, I get the error:
Could not resolve view with name '/todos/index' in servlet with name 'grailsDispatcherServlet'
Snapshot of the error is below.
I spend many times to find out where it is, but no magic thing happens to me.
Anyone got such a situation?
Sounds like you've confused Grails slightly. Best thing to do in this case is to stop your application and run the clean
command and try again. The reason is, that Grails compiled your initial Controller into the build
directory, where the .class
file still remains (even when the .groovy
file is gone). The component scan still picks the class from the class path up and you end up with the two controllers.