I am currently creating a CRUD tool for an existing Spring application. The application is included in the Grails application as a JAR library that works fine.
To use the library's native spring context, I used it to load through:
def ctx = new ClassPathXmlApplicationContext( 'classpath:/applicationContextName.xml')
in my service. Unfortunately, the context creates its own data source (the default library), which is not suitable, since I need to use the dataSource defined in Grails.
So my solution was to simply enable the spring library configuration with Grails content by adding import to the grails-app \ conf \ spring \ resources.xml file.
This seems to work (since all beans are loaded in the same context, and now I can autowire beans directly into my service classes using def variableName .
Unfortunately, the dataSource defined in the spring config library overloads the dataSource defined in my Grails file DataSource.groovy!
Is there any way to understand that Grails is loading the libary spring configuration so that it is then overridden by the rest of the Grails configuration (and therefore using the DataSource Grails)?
Thanks for your help,
James
...
As a temporary measure, I deleted the dataSource entry in the spring dependencies configuration file and its beans were injected with the data source created by the Grails configuration, but this is not ideal, since I had to do a βspecialβ build of the dependency ban.
source share