Springboot项目导可执行jar

  1. 1.pom.xml配置:
  2. 2.Run AS ->Maven clean
  3. 3.Run AS ->Maven install

1.pom.xml配置:

<build>
    <resources>
        <!--指定src/main/resources资源要过滤-->
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
    <plugins>
        <!-- 可执行jar插件 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>lib/</classpathPrefix>
                        <mainClass>cn.com.sinodata.AppRun</mainClass>
                    </manifest>
                    <manifestEntries>
                        <Class-Path>.</Class-Path>
                    </manifestEntries>
                </archive>
                <excludes>
                    <!-- <exclude>**/*.xml</exclude>
                    <exclude>**/*.conf</exclude>
                    <exclude>**/*.properties</exclude> -->
                    <exclude>**/*.yml</exclude>
                    <exclude>**/logback-spring.xml</exclude>
                    <exclude>**/*.sh</exclude>
                </excludes>

            </configuration>
        </plugin>
        <!-- maven资源文件复制插件 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.7</version>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <!-- here the phase you need -->
                    <phase>package</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/LottSellNetManage</outputDirectory>
                        <resources>
                            <resource>
                                <directory>src/main/resources</directory>
                                <includes>
                              <!--       <exclude>**/*.xml</exclude>
                                    <exclude>**/*.conf</exclude>
                                    <exclude>**/*.properties</exclude> -->
                                    <exclude>**/*.yml</exclude>
                                    <exclude>**/logback-spring.xml</exclude>
                                    <exclude>**/*.sh</exclude>
                                </includes>
                                <filtering>true</filtering>
                            </resource>
                        </resources>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <!-- 依赖包插件 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/LottSellNetManage/lib</outputDirectory>
                        <!-- 是否不包含间接依赖 -->
                        <excludeTransitive>false</excludeTransitive>
                        <!-- 忽略版本 -->
                        <stripVersion>false</stripVersion>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <skipTests>true</skipTests>
            </configuration>
        </plugin>
    </plugins>
</build>

2.Run AS ->Maven clean

3.Run AS ->Maven install

文章标题:Springboot项目导可执行jar

发布时间:2019-11-14, 15:26:12

最后更新:2019-11-14, 15:26:12