Reputation: 171
I am attempting to run an application. I have gmaven so it can build. Basically, I am trying to run a script everytime the application starts where it parses and XML file and populates a database using the existing data access objects. I am unclear of where I should put the script etc. Has anyone had experience regarding this? Not sure if it's relevant, but the project I am working on uses JPA.
Upvotes: 0
Views: 554
Reputation: 123910
Write a Groovy class, put it in some package below src/main/groovy, register it as a Spring bean, inject the DAO(s), and make sure that one of the methods of the Groovy class gets executed when the Spring container starts up (see Execute method on startup in Spring). Essentially no difference to how you would do it in Java.
Upvotes: 1