8月19
Tess4j Issue in Windows: java.lang.UnsatisfiedLinkError: The specified module could not be found in instance.doOCR(imageFile)

Tess4j在本地跑的时候没有问题,放到windows server2008 r2服务器上的时候就报下面找不到模块的错误:

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]

我搜索并发现人们建议更新Visual VisualC++可重分发软件包,我做了Visual Studio 2013,但结果却没有帮助,我仍然得到同样的问题。我不知道我做错了什么,下面是我的代码。

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());
}


此问题与Windows无关。
我已经把版本换回3.0
<dependency>
       <groupId>net.sourceforge.tess4j</groupId>
       <artifactId>tess4j</artifactId>
       <version>3.0.0</version>
</dependency>
替换所有以前的maven依赖项,就好了。
8月5
x-www-form-urlencoded方式:

Map<String,Object>  map = new HashMap<>();
map.put("page_size","100")
map.put("ps", "100")
map.put("page_flag", "true")
Document doc = Jsoup.connect("http://www.zgetfl.org/qget/main_qget/sqgl/apLcChildAction.do?method=listApLcChildnew")
                    .header("useragent","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36")
                    .header("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")
                    .data("page_size","100")
                    .data("ps", "100")
                    .data("page_flag", "true")
                    .post();

application/json方式:

Map<String,String> map = new HashMap<>();
map.put("username","aaaa");
map.put("password","123456");
Gson gson = new Gson();
String parameter = gson.toJson(map);
Document doc = Jsoup.connect("localhost:8080/api/user/login")
                    .header("useragent","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36")
                    .requestBody(parameter)
                    .ignoreContentType(true)
                    .post();
分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]