1

I don't understand why this doesn't work; it seems like tutorials that use spring boot and angular as maven modules end up running things directly with java instead so this problem doesn't exist there... but I think this should still work right?

TO RUN I am trying to run "mvnw spring-boot:run" from the parent POM (there is only one mvnw.cmd file and its in the parent folder).

THE ERROR "No plugin found for prefix 'spring-boot' in the current project and in the plugin groups"

Parent POM:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>project.site.org</groupId>
    <artifactId>artifactID</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <modules>
        <module>frontend</module>
        <module>backend</module>
    </modules>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

Spring Boot Module POM

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <groupId>project.site.org</groupId>
    <artifactId>backend</artifactId>
    <packaging>jar</packaging>
    <name>backend</name>

    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>5.3.3</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.4.2</version>

            </plugin>
        </plugins>
    </build>

</project>

Angular POM

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>project.site.org</groupId>
        <artifactId>videowall</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <groupId>project.site.org</groupId>
    <artifactId>frontend</artifactId>
    <packaging>jar</packaging>
    <name>frontend</name>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
    </resources>
    <plugins>
    </plugins>
  </build>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

</project>
gunslingor
  • 1,358
  • 12
  • 34

2 Answers2

1

-pl lets you run the Maven command against specific module from the project root. In this case:

./mvnw spring-boot:run -pl backend
Maciej Walkowiak
  • 12,372
  • 59
  • 63
0

You can execute mvn commands from where the mvnw script is stored, or you can provide the path for the same. Is there an mvnw directory at that level?

This might help: How to run Maven from another directory (without cd to project dir)?

  • no, only the parent directory has this folder – gunslingor Mar 02 '21 at 13:48
  • Please check the link I've attached if that helps. –  Mar 02 '21 at 13:50
  • thanks, I was missing the -f option. Also, I see I duplicated the question and this solution seems to work great, though I don't like having a spring plugin defined in the parent when its only applicable to the child and I don't fully get why this works or what it might break =). https://stackoverflow.com/questions/41092200/run-mvn-spring-bootrun-from-parent-module – gunslingor Mar 02 '21 at 13:53