I'm migrating a Grails 2.5 application to Grails 3.0.9
and having some issue reading a classpath resource in grails-app/init/BootStrap.groovy
.
In Grails 2.5.x it was possible to access resource (e.g. textfiles) using the Spring ClassPathResource
when putting the resource file into the same folder as the BootStrap.groovy
def file1 = new ClassPathResource('my-textfile.txt').file
In Grails 3 it works when I start my application using grails run-app
. All resources are taken from src/main/resources
. But if I start the application using the Spring Boot Application (located at /grails-app/init/a/b/Application.groovy
) class in IntelliJ the BootStrap.groovy find the resources anymore.
Does anyone know how to access these files within BootStrap.groovy
in Grails 3.0.9 when starting the app using Application.groovy
?
According to the Gradle convention I place the resources under src/main/resource
since they need to be accessible at runtime.
For some reasons my grails-app/init/a/b/Application.groovy
can't find these resources so I had to place a symbolic link to grails-app/init/a/b
. After that everything works as expected.