Maven exec:java goal on a multi-module project

Goals in a multi-module project, when run from the parent, will run against all modules. I don’t think that’s what you want. You can try:

mvn exec:java -pl module2 -Dexec.mainClass=MyMain

That might work? More info:

However, I think it’s more intuitive to change directory to the sub-module containing the executable before running it.

Leave a Comment