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

相关推荐
IMPYLH26 分钟前
Linux 的 dir 命令
linux·运维·服务器·数据库
fanged34 分钟前
操作系统番外1(Linux的测试体系)(TODO)
linux·运维·服务器
Zzxy1 小时前
快速搭建SpringBoot项目并整合MyBatis-Plus
java·spring boot
zjjsctcdl2 小时前
springBoot发布https服务及调用
spring boot·后端·https
123过去2 小时前
pixiewps使用教程
linux·网络·测试工具·算法·哈希算法
观测云2 小时前
SpringBootAI 接入观测云 MCP 最佳实践
spring boot·观测云·mcp
zdl6862 小时前
Spring Boot文件上传
java·spring boot·后端
RMB Player2 小时前
Spring Boot 集成飞书推送超详细教程:文本消息、签名校验、封装工具类一篇搞定
java·网络·spring boot·后端·spring·飞书
H_老邪3 小时前
Linux 与 Docker 常用命令
linux·运维·服务器·docker
yewq-cn3 小时前
linux 内核设备号
linux·运维·服务器