SpringBoot-maven packaging local jar package notes

I found a lot of articles on the Internet, and combined them to achieve a successful package configuration. Record it here.

1. SpringBoot project directory

jar in the lib folder

2. The way to introduce the jar package: File -> Project Structure to add the jar to the project

3. The key configuration of maven pom.xml

 <build>

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

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <!--设置为 true 则跳过测试-->
                    <skip>true</skip>
                    <compilerArgs>
                        <arg>-extdirs</arg>
                        <arg>${project.basedir}/lib</arg>
                    </compilerArgs>

                </configuration>
            </plugin>

        </plugins>

        <resources>
            <!--拷贝jar-->
            <resource>
                <!--需要打包的jar路径-->
                <directory>lib</directory>
                <!--复制到的路径-->
                <targetPath>BOOT-INF/lib/</targetPath>
                <includes>
                    <include>**/*.jar</include>
                </includes>
            </resource>

            <!--不配置这个会丢失resources目录的文件-->
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*</include>
                </includes>
                <!--To prevent corrupting your binary files when filtering is enabled, you can configure a list of file extensions that will not be filtered.
                翻译:为了避免开启 filter后你的二进制文件被损毁,你可配置不被过滤的文件拓展名列表-->
                <!--必须设置成fasle否则rpt文件签名不一致,造成水晶报表无法正确显示-->
                <filtering>false</filtering>
            </resource>
        </resources>

    </build>

 

Guess you like

Origin blog.csdn.net/cs373616511/article/details/109266228