2

how can I run child module plugin goal when I build the main project

I want to run spring-boot plugin after build the project, but the spring-boot plugin only added in the submodule, is there any solution? thanks always!

main-project
    pom.xml
        spring-boot plugin not added in the main pom.xml
    module1
        pom.xml
    module2
        pom.xml
            depend on module1
            spring-boot plugin added

when I run the command

mvn clean install -pl module2 -am spring-boot:run

the maven throws excption

[ERROR] No plugin found for prefix 'spring-boot' in the current project and in the plugin groups
taotao
  • 33
  • 7
  • Why do you want to do that? And not just execute multiple times maven? – Simon Martinelli Jun 12 '19 at 06:46
  • in you suggest i can build all module `mvn clean install` and then `cd module2` `mvn spring-boot:run` this can work, but i want to run the mvn command only once to run the spring-boot:run goal. – taotao Jun 12 '19 at 06:52
  • Why? if you do ````mvn clean install && cd module2 && mvn spring-boot:run```` you have all in one line too. I assume that your main project has a module section so it will build all modules. – Simon Martinelli Jun 12 '19 at 06:57
  • great idea, i only need to write command in one line, lol, thansk :-) – taotao Jun 12 '19 at 07:04
  • Great that you like my answer. I add this as an answer and I would appreciate it if you could accept this as the correct answer. Thank you – Simon Martinelli Jun 12 '19 at 07:07

1 Answers1

1

If you do

mvn clean install && cd module2 && mvn spring-boot:run 

you have all in one line too.

I assume that your main project has a module section so it will build all modules.

Simon Martinelli
  • 34,053
  • 5
  • 48
  • 82