springboot项目引用外部jar包,linux部署后启动失败,找不到jar包

1.pom文件引入依赖

bash 复制代码
        <!-- https://mvnrepository.com/artifact/com.aspose/aspose-words -->
        <dependency>
            <groupId>com.aspose</groupId>
            <artifactId>aspose-words</artifactId>
            <version>18.6.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/aspose-words-18.6.0.jar</systemPath>
            <type>jar</type>
            <optional>true</optional>
        </dependency>

2.系统lib包下放入外部jar包

3.pom文件修改打包代码,指定读取jar包

bash 复制代码
<!-- 打包时候用 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>com.example.SpringbootInit</mainClass>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib</classpathPrefix>
                        </manifest>
                        <manifestEntries>
                            <!--读取外部配置文件,放到classpath里 -->
                            <Class-Path>resources/. lib/aspose-words-18.6.0.jar</Class-Path>
                        </manifestEntries>
                    </archive>
                    <outputDirectory>${project.build.directory}</outputDirectory>
                    <excludes>
                        <exclude>**/*.properties</exclude>
                    </excludes>
                </configuration>
            </plugin>

在打包的时候指定读取外部的jar包,这样部署到linux后,启动就不会报找不到jar包的错误了

相关推荐
e***8908 小时前
MySQL 8.0版本JDBC驱动Jar包
数据库·mysql·jar
小白同学_C8 小时前
Lab4-Lab: traps && MIT6.1810操作系统工程【持续更新】 _
linux·c/c++·操作系统os
今天只学一颗糖8 小时前
1、《深入理解计算机系统》--计算机系统介绍
linux·笔记·学习·系统架构
不做无法实现的梦~10 小时前
ros2实现路径规划---nav2部分
linux·stm32·嵌入式硬件·机器人·自动驾驶
+VX:Fegn089511 小时前
计算机毕业设计|基于springboot + vue鲜花商城系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计
识君啊12 小时前
SpringBoot 事务管理解析 - @Transactional 的正确用法与常见坑
java·数据库·spring boot·后端
默|笙12 小时前
【Linux】fd_重定向本质
linux·运维·服务器
陈苏同学12 小时前
[已解决] Solving environment: failed with repodata from current_repodata.json (python其实已经被AutoDL装好了!)
linux·python·conda
CaracalTiger12 小时前
如何解决Unexpected token ‘<’, “<!doctype “… is not valid JSON 报错问题
java·开发语言·jvm·spring boot·python·spring cloud·json
“αβ”12 小时前
网络层协议 -- ICMP协议
linux·服务器·网络·网络协议·icmp·traceroute·ping