经过 2 天的谷歌搜索后,我仍然无法找到 Tess4j 3.0 版问题的解决方案:java.lang.UnsatisfiedLinkError:找不到指定的模块。
我在我的 Windows 10 x64 上编写服务器端 Spring Boot 应用程序。我使用了这个教程http://tess4j.sourceforge.net/tutorial/
我ant test
在 tess4j 项目的源代码中制作,这个命令在我的电脑上运行正常。我还安装了适用于 VS2012 的 Visual C++ Redistributable 和适用于 VS2013 的 Visual C++ Redistributable。但是我错过了我的 PC 中的 dll,libtesseract304.dll 取决于:
这可能是问题的原因吗?但是,Tess4J-3.0-src 项目怎么可能在我的电脑上正常工作?
我的完整堆栈跟踪:
java.lang.UnsatisfiedLinkError: The specified module could not be found.
at com.sun.jna.Native.open(Native Method) ~[jna.jar:4.2.1 (b0)]
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:263) ~[jna.jar:4.2.1 (b0)]
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:403) ~[jna.jar:4.2.1 (b0)]
at com.sun.jna.Library$Handler.<init>(Library.java:147) ~[jna.jar:4.2.1 (b0)]
at com.sun.jna.Native.loadLibrary(Native.java:502) ~[jna.jar:4.2.1 (b0)]
at com.sun.jna.Native.loadLibrary(Native.java:481) ~[jna.jar:4.2.1 (b0)]
at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(Unknown Source) ~[tess4j-3.0.jar:na]
at net.sourceforge.tess4j.TessAPI.<clinit>(Unknown Source) ~[tess4j-3.0.jar:na]
at net.sourceforge.tess4j.Tesseract.init(Unknown Source) ~[tess4j-3.0.jar:na]
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source) ~[tess4j-3.0.jar:na]
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source) ~[tess4j-3.0.jar:na]
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source) ~[tess4j-3.0.jar:na]
at ocr.OCRController.handleFileUpload(OCRController.java:109) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_51]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_51]
我的代码:
ITesseract instance = new Tesseract(); // JNA Interface Mapping
instance.setDatapath(new File(datapath).getPath());
instance.setLanguage("eng");
try {
String result = instance.doOCR(imageFile); //error here
} catch (TesseractException e) {
System.err.println(e.getMessage());
}
行家:
<dependency>
<groupId>jai_imageio</groupId>
<artifactId>com.jai_imageio</artifactId>
<version>3.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jai_imageio.jar</systemPath>
</dependency>
<dependency>
<groupId>commons-io-2.4</groupId>
<artifactId>com.commons-io-2.4</artifactId>
<version>3.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/commons-io-2.4.jar</systemPath>
</dependency>
<dependency>
<groupId>jna</groupId>
<artifactId>com.jna</artifactId>
<version>3.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jna.jar</systemPath>
</dependency>
<dependency>
<groupId>tess4j-3.0</groupId>
<artifactId>com.tess4j-3.0</artifactId>
<version>3.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/tess4j-3.0.jar</systemPath>
</dependency>
我还尝试以强制方式加载库:
Runtime.getRuntime().loadLibrary("lib/win32-x86-64/gsdll64");
Runtime.getRuntime().loadLibrary("lib/win32-x86-64/libtesseract304");
但没有成功:
There was an unexpected error (type=Internal Server Error, status=500).
C:\Users\Iuliia\IdeaProjects\ENumbersBackend\lib\win32-x86-64\libtesseract304.dll: Can't find dependent libraries
感谢您的任何帮助!