I've created new application in Grails 3.0.3 using console:
grails create-app hello
and it's running fine with:
grails run-app
But now, I would like to change the package name where Application.groovy is located (original location is hello/grails-app/init/hello/Application.groovy) to something else, eg hello/grails-app/init/foo/Application.groovy. When I'm trying to start application after change there is exception:
Error: Could not find or load main class hello.Application
Source of the Application.groovy file is (generated by grails, except 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 be able to rename this package?
EDIT: In the documentation there is a fragment:
grails-app/init/PACKAGE_PATH/Application.groovy The Application class used By Spring Boot to start the application
But still don't know what is PACKAGE_PATH and how to set this.
If your package statement matches the directory structure then it should just work. Run ./gradlew clean run
.
After 2 hours of investigation and based on the Jeff's answer, here is the detailed explanation:
grails-app/init/foo/Application.groovy
grails run-app
) and things worked fineApplication.groovy
to com.test
instead of foo
Could not find or load main class foo.Application
grails clean
and then grails run-app
but it didn't work because gradle build was not cleanmainClassName
or mainClass
under build.gradle
but nothing workedFinally doing ./gradlew clean
made it to work so it is clear that grails clean
is not actually cleaning the gradle build.
For windows, just run gradlew.bat clean
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With