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包的错误了

相关推荐
xlp666hub4 小时前
Leetcode第五题:用C++解决盛最多水的容器问题
linux·c++·leetcode
张宏2365 小时前
原子操作 (基于Linux 应用层 C 语言)
linux
kymjs张涛20 小时前
OpenClaw 学习小组:初识
android·linux·人工智能
程序设计实验室1 天前
经历分享,发现挖矿木马后,服务器快速备份与重装(腾讯云平台)
linux
Miku161 天前
OpenClaw-Linux+飞书官方Plugin安装指南
linux·人工智能·agent
Miku161 天前
OpenClaw 接入 QQ Bot 完整实践指南
linux·人工智能·agent
悟空码字1 天前
Spring Boot 整合 MongoDB 最佳实践:CRUD、分页、事务、索引全覆盖
java·spring boot·后端
Yogurt_cry1 天前
[树莓派4B] 闲置近10年的爱普生 L310 打印机爆改无线打印机
linux·物联网·树莓派
Johny_Zhao2 天前
OpenClaw中级到高级教程
linux·人工智能·信息安全·kubernetes·云计算·yum源·系统运维·openclaw
皮皮林5513 天前
拒绝写重复代码,试试这套开源的 SpringBoot 组件,效率翻倍~
java·spring boot