How do I change the location of the Application.groovy class in Grails 3.0.3?
I created a new application in Grails 3.0.3 using the console:
grails create-app hello
and it works fine:
grails run-app
But now I would like to change the name of the package where Application.groovy resides (original location hello / grails-app / init / hello / Application.groovy) to something else like hello / grails-app / init / foo / Application.groovy. When I try to start the application after the change, there is an exception:
Error: Could not find or load main class hello.Application
Source of Application.groovy file (generated by grails besides package name)
package foo
import grails.boot.GrailsApp
import grails.boot.config.GrailsAutoConfiguration
class Application extends GrailsAutoConfiguration {
static void main(String[] args) {
GrailsApp.run(Application, args)
}
}
Any hints where should I change something to rename this package?
EDIT: There is a snippet in the documentation:
grails-app/init/PACKAGE_PATH/Application.groovy The Application class used By Spring Boot to start the application
But still don't know what PACKAGE_PATH is and how to set it.
source to share
After 2 hours of investigation and based on Jeff's answer, here is a detailed explanation:
- I created a sample app named foo which created
grails-app/init/foo/Application.groovy
- I ran the app (using
grails run-app
) and everything worked fine - Later I changed the package
Application.groovy
tocom.test
instead offoo
- Error with error
Could not find or load main class foo.Application
- I kept trying
grails clean
and thengrails run-app
, but it didn't work because gradle build was not clean - I tried setting
mainClassName
ormainClass
inbuild.gradle
but nothing worked
Finally done ./gradlew clean
, it worked, so it is clear that grails clean
it doesn't actually clean up the gradle build.
For windows, just rungradlew.bat clean
source to share