Springboot 配置so库遇到UnsatisfiedLinkError时候的检测方法

本文介绍了解决Springboot项目中遇到UnsatisfiedLinkError的方法,特别是当缺失.so库文件时如何通过配置Maven来正确打包so文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

遇到UnsatisfiedLinkError的时候,说明找不到这个so库:
在这里插入图片描述
假设的确已经配置了正确的路径和查找方法,可以参见https://xiangyang.blog.csdn.net/article/details/90259838

那么需要考虑是否IDEA在打包的时候把Resource下的so库打包进了jar包
通过使用jar命令查看jar包内容

jar -tf 包名.jar | grep so库名称

如果能顺利打印出类似于以下的路径,说明打包的时候顺利添加了该动态库,反之则没有
在这里插入图片描述
如果确认没有添加该包,需要在maven的build部分中添加以下信息:

	<build>
		<resources>
			<resource>
				<directory>src/main/resource</directory>
				<includes>
					<include>**/*.properties</include>  
					<include>**/*.xml</include>
					<include>**/*.so</include>
				</includes>
				<filtering>false</filtering>
			</resource>
		</resources>
	</build>

重点在于<include>**/*.so</include>,这样就能将so库打进jar包了

说到底还是Springboot半路出家,需要更多学习才行……

参考链接:https://blog.csdn.net/qq_38588736/article/details/106425504

https://www.jianshu.com/p/0226a2a5a836

https://stackoverflow.com/questions/2937406/how-to-bundle-a-native-library-and-a-jni-library-inside-a-jar
https://stackoverflow.com/questions/57466273/filenotfoundexception-in-spring-boot-jar-but-the-file-is-present

http://xiaoyue26.github.io/2019/09/08/2019-09/JNI%E5%A6%82%E4%BD%95%E4%BC%98%E9%9B%85%E5%BC%95%E7%94%A8so%E6%96%87%E4%BB%B6/

操作系统判断:https://github.com/kwhat/jnativehook/blob/master/src/java/org/jnativehook/NativeSystem.java

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值