Java – use POM to wrap the spring boot of agrigator

Is it possible to use the spring boots Maven plug-in command spring boot: run when the parent POM of the project uses the packaging mode POM because of its child nodes?

I have a multi module Maven project with a "master" POM, which is a child of the spring boot parent module It looks like this:

<modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>project</artifactId>
    <packaging>pom</packaging>
    <version>0.1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.0.BUILD-SNAPSHOT</version>
        <relativePath/>
    </parent>

    <modules>
        <module>module1</module>
        <module>module2</module>
        <module>module3</module>
    </modules>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <start-class>com.example.module1.Application</start-class>
        <java.version>1.8</java.version>
    </properties>

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

This is basically our "master" POM, and every child uses it as its parents Now we will execute the spring boot: run command from the working directory where the "master" POM is located The problem is that this will produce a strange classnotfoundexception, because module1 (where the application class is located) is included in POM and mentioned as a module

Using a single module Maven project and < packaging > jar < / packaging > will compile and run the application class, so spring boot does not work here

When dealing with the multi module Maven project, what do I need to do to change it in order to use the spring boot Maven plugin plug-in?

Side note: my application class / module 1 has other modules as dependencies, so keep this in mind when answering questions Any suggestions on how to improve this will be greatly appreciated

Solution

As far as I know, this is impossible because the plug-in needs an executable jar to run

The "running" document of the spring boot plugin target says:

Wrapping POM does not create an executable It only generates a POM xml.

Try running MVN install and view the artifacts deployed to the local repository:

I just did one thing for the module packaging POM:

[INFO] Installing C:\projects\boot-parent\pom.xml to 
C:\Users\...\repository\no\boot-parent\0.0.1-SNAPSHOT\boot-parent-0.0.1-SNAPSHOT.pom

As you can see, the artifact is boot-parent-0.0 1-SNAPSHOT. pom.

Try to put the plug - in configuration in the POM of module 1 with start - class (main - class) and packaged jar

Edit your comment:

Your comments indicate that there is a problem with your client Maven installation Look at this answer Especially the answer given by @ Christian Achilli

Again, I hope it helps!

Thomas

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>