*Mixing Springboot components in a Grails applicat...
# questions
u
Mixing Springboot components in a Grails application: We have a legacy Grails application of significant size using Grails 6.2.x and Java 17. We are trying to convert this application into a Springboot application (rest of our applications are all Springboot, this being the only exception). The approach we are thinking of taking is to incrementally do this conversion. So take one or two Grails controllers and services at a time and convert them into Springboot. And we are hoping that we would be able to run the application as a mix of the two for a while until we complete this conversion. I was wondering if anyone else here has the experience of converting a Grails application into a Springboot application and can share their wisdom/learnings etc. Thanks.
u
thread
j
You can already define beans in the spring style and they're available via the normal means since grails is built on top of spring. So services should be just simply annotation with the associated spring annotation. I will say that you'll want those services in a separate location and you may face difficulty with the AST transforms still applying to them.
For the controllers, that's tougher since grails subclasses Spring's dispatcher servlet. I'm not sure how you can have spring controllers and grails controllers side by side when grails is in controller of the traffic to the controllers
u
We have done a quick POC with converting one controller. We added @ComponentScan for the path where the converted springboot controller is and routing/dispatching seems to be working fine. However we needed to keep the converted controller in src/main/groovy (as against src/main/java) so it can access the groovy services. One of the issue we are running into is with unit tests. We need some way to populate the combined grails + springboot context in the unit test and we are currently struggling with that.