0

I have a Maven Spring Boot Micro Services Java project arranged into a parent module and 6 sub-modules. In the parent pom.xml, I have included the Maven Spring Boot Plugin in the build/plugins section: -

    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>2.1.5.RELEASE</version>
    </plugin>

5 of my 6 sub-modules are Micro Services, and the above plugin ensures that these are built into executable Spring Boot jars, including all dependencies, when I run mvn clean install

However, the other sub-module is just a standard Java utility project and does not have a Spring Boot context. When I try to build, I see the following error: -

 Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.1.5.RELEASE:repackage failed: Unable to find main class -> [Help 1]

This is expected as this sub-module is not a Spring Boot application and does not have a main class. I tried to fix this by overriding the Spring Boot Maven plugin in the pom file of that sub-module so that it is treated as a standard 'thin' jar: -

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <dependencies>
                <!-- The following enables the "thin jar" deployment option. -->
                <!-- This creates a normal jar, not an executable springboot jar -->
                <dependency>
                    <groupId>org.springframework.boot.experimental</groupId>
                    <artifactId>spring-boot-thin-layout</artifactId>
                    <version>1.0.11.RELEASE</version>
                </dependency>
            </dependencies>
        </plugin>

However, I am still seeing exactly the same error in my Maven build. I would be most grateful for any hints or pointers on this one.

Jon H
  • 394
  • 3
  • 17
  • Sounds like you don't want the Spring plugin to run in that module at all, so you can just use standard Maven compiler plugin. In which case, you can bind the Spring plugin to phase `none` to disable it for that module, as described in https://stackoverflow.com/questions/7821152/disable-a-maven-plugin-defined-in-a-parent-pom – Michael Jul 30 '20 at 11:26
  • @Michael Many thanks for the suggestion. I am giving it a try. No luck yet and I am not sure what to specify as execution/id. I'll keep digging and trying! – Jon H Jul 30 '20 at 12:10
  • It can be arbitrary. Just give it some ID at the parent level, "jons-magic-plugin", and reuse the same ID in the child. – Michael Jul 30 '20 at 12:30
  • @Michael Great - this also works, as does the solution below. Many thanks, two possible solutions in the bank now! :) – Jon H Jul 31 '20 at 16:06

1 Answers1

1

You can skip the execution of the repackage plugin for your utility module by overriding the configuration in that module.

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <skip>true</skip>
    </configuration>
</plugin>
Dharman
  • 30,962
  • 25
  • 85
  • 135
Bernard
  • 333
  • 2
  • 8