Configuring IntelliJ IDEA to achieve Maven project package

1. Add the configuration in the pom.xml file

<!--编译打包插件-->
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                        	<!-->此处设置成主类的类全名<-->
                            <mainClass>com.TomAndersen.AppMain</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

2. Use Maven project tool Packager

  • Use Maven-Lifecycle-package assembly

    Use package components

  • Console output
    Console output

3. Generate jar package

  • After the package will succeed srcat the same level directory targetfolder generated with and without dependent dependent jar package, the package name prefix and artifactIdthe same
    Generating two jar package
  • NOTE 1: If the package does not have dependencies jar, the procedure relies on the implementation of the local operating environment
  • Note 2: If you use the jar package program depends band, the program does not rely on the local operating environment is executed, and only depends on the development environment
Published 15 original articles · won praise 5 · views 10000 +

Guess you like

Origin blog.csdn.net/TomAndersen/article/details/104245064