我创建了一个使用 google or-tools 的 spring 应用程序。为此,我使用 System.loadLibrary("jniortools") 导入 jniortools。当我提供 .dll 文件并运行 war 文件时,它运行得很好。但是当我在 lib 中提供 .so 文件路径时,出现 unsatisfiedlinkerror。
最佳答案
取自 here ,在 Intellij 上使用 or-tools 的解决方案:
要使其使用 Intellij(在 Windows 计算机上)工作,您需要:
- 安装Microsoft Visual C++ Redistributable for Visual Studio
- 下载并解压OR-Tools library for Java
- 在 intellij 中,add jar dependency到解压文件的 lib 文件夹下的 2 个 jar(这 2 个 jar 分别添加,不要添加到 lib 文件夹本身。This is why)。
- 将 lib 库路径添加到 VM 选项。在 Intellij 中编辑您的运行配置并添加到虚拟机选项:
-Djava.library.path=<path to the lib folder that hold the jars>
通过将以下代码添加到您的类中来静态加载 jni 库(如前所述 here 。)
static { System.loadLibrary("jniortools"); }
关于java - 谷歌或工具: UnsatisfiedLinkError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61853678/