maven项目中引入本地jar包配置

服务在本地可以正常运行,打包后放在服务器就无法运行,原来是引入的本地jar包maven没有打包上去

首先jar包是放在资源目录下的lib里

pom文件在引入时指定jar包的路径,maven引入不会报错,但是打包后没有这个jar包

        <dependency>
            <groupId>com.sun.jna.examples</groupId>
            <artifactId>com-sun-jna-example</artifactId>
            <version>1.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/resources/lib/examples.jar</systemPath>
        </dependency>

网上搜了挺多之后,发现在pom文件得加入以下配置才行,指定在打包时要加入lib中的内容

<plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.3.2.RELEASE</version>
                <executions>
                    <execution>
                        <id>repackage</id>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <arguments>
                        <argument>${project.basedir}/src/main/resources/lib</argument>
                    </arguments>
                    <includeSystemScope>true</includeSystemScope>
                    <mainClass>com.test.demo.TestApplication</mainClass>
                </configuration>
            </plugin>
posted @ 2024-09-05 14:04  划水的鱼dm  阅读(194)  评论(0)    收藏  举报