springBoot项目导入自己jar包

springboot项目导入自己的jar包

1.当我们在springBoot项目中导入自己的jar包时,在本地启动是没有问题的,但是当我们将springBoot项目打成jar包然后放到linux服务器时,就会出现jar包找不到的问题。下面就是解决方法
(1)我的自己的jar包路径:
在这里插入图片描述

(1)在pom文件中添加配置

<!--        设置自定义jar包资源-->
        <dependency>
            <groupId>common</groupId>
            <artifactId>common</artifactId>
            <version>1.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/common-v1.jar</systemPath>
        </dependency>

注意:下面的打包插件也要改
在这里插入图片描述
代码:

<!--    插件,maven打包插件-->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.4.3</version>
                <configuration>
                    <executable>true</executable>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

猜你喜欢

转载自blog.csdn.net/m0_44980168/article/details/130002810
今日推荐