How to make a "thick jar" project Maven?

Using IntelliJ I just created a new Maven project and added the following to the pom file http://undertow.io/downloads.html and the following to the Main.java file http://undertow.io/index.html

Now, if I run the code, everything works fine, but how can I do it as a "live jar" that will contain all the dependencies in the pom file and what can I just run java -jar my.jar? How can you do with the Spring Boot app.

+4
source share
2 answers

Maven Shade Plugin does it well.

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-shade-plugin</artifactId>
      <version>2.4.3</version>
      <executions>
        <execution>
          <phase>package</phase>
          <goals>
            <goal>shade</goal>
          </goals>
          <configuration>
            <transformers>
              <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                <mainClass>package.Main</mainClass>
              </transformer>
            </transformers>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
+12
source

1) Spring-boot-maven-plugin pom.xml

 <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.4.0.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

2)

<packaging>jar</packaging>

3) mvn package .

+5

Source: https://habr.com/ru/post/1652112/


All Articles