-
-
Notifications
You must be signed in to change notification settings - Fork 953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grails Application is not annotated with @SpringBootApplication or @SpringBootConfiguration #14012
Comments
@rainboyan Do you have any thoughts on this problem? Someone mentioned you solved a similar issue with Grace. |
@jdaugherty Could you provide a minimal sample to reproduce the problem and give me some details about the errors? |
You can see an example here: https://github.com/grails/grails-core/blob/7.0.x/grails-test-examples/app1/src/integration-test/groovy/functionaltests/ConfigTestControllerSpec.groovy This class adds an Application class for the test, but it does not invoke that class. I only noticed this because we changed the banner and that test showed a Spring banner instead of a grails banner. If you annotate the Application class with '@SpringBootApplication
|
The reason to do this is in case someone is doing any setup prior to calling run app. This ensures the tests also execute the same logic that the other run methods use. |
The Spring Boot banner also displays on Grails commands instead of the Grails banner, such as:
with grails 7.0.0-SNAPSHOT and grails-database-migration:6.0.0-M1 |
@jdaugherty Sorry, I don't quite understand what you mean, the example app only have one application class I think the problem you describe should be related to Grails integration testing, especially the use of '@Integration'. This is a Groovy ASTTransformation, What it does is add the annotation As far as I know, Grails doesn't currently support the use of Maybe I said before, Grails applications are not exactly Spring Boot applications. That why we should add We can do this in But I think '@SpringBootApplication' should be used to make sure Grails is consistent with Spring Boot. |
@rainboyan Thank you. I think it makes sense to add one of these annotations based on your comment - this background is what I needed. You're right this test doesn't have multiple application classes, but if you debug it, you'll see it's never invoking the one that exists in the project for tests because of the missing annotation / spring boot test setting. This in turn is what's causing the wrong banner on running the test. Thank you for also pointing out @matrei @codeconsole @jamesfredley What are your thoughts about |
Looking at the ApplicationClassInjector, it looks like it needs to take into account the |
Issue description
In attempting a merge of the mongodb & data-mapping repos, it was noticed that unless the Application class is annotated with
@SpringBootApplication
then the grails test could not use a different application class. The test also had to be annotated with@SpringBootTest(useMainMethod = SpringBootTest.UseMainMethod.ALWAYS)
The text was updated successfully, but these errors were encountered: