0

I am using the Exec Maven Plugin to run a main method when using a specific profile. For example:

mvn process-resources -Psomeprofile

In this method, I want to be able to run code that performs operations on my database using my application code, however the database is not connected at this point. I normally use spring for resource injections of some service classes, but that is also not possible since main() is static. Is there some way to load my applicationContexts and have my application built and run a program through maven?

eipark
  • 7,442
  • 3
  • 24
  • 33
  • Why not using an integration test for such purposes? You don't need a main which static you can use things like TestNG for such things. – khmarbaise May 01 '13 at 16:17
  • This is not a test though, it's a utility I need to maintain objects in my database through application code. – eipark May 01 '13 at 16:35
  • It's neither test nor main code, so this utility code should not be placed there(and should especially not end up in the final artifact). Rather have it separately (./src/util/java for instance): a class with that utility code and with spring context obtained programmatically. Get it a special treatment in your pom. The pom will get pigged out and complex though. Maybe with more details in hand some more elegant solution would appear. What's the output of that utility code afterall? Why in process-resources? – patrungel May 01 '13 at 19:30

0 Answers0