首先
1、安装 Tesseract 否则不能用
brew install tessarct
2、idea 建工程 引入 依赖
<!-- https://mvnrepository.com/artifact/net.sourceforge.tess4j/tess4j --> <dependency> <groupId>net.sourceforge.tess4j</groupId> <artifactId>tess4j</artifactId> <version>5.2.1</version> </dependency> <!-- 解决方式为排除冲突包 --> <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.36</version> </dependency>
3、建立包文件 jar
mkdir darwin
cp /Users/你的用户名/.m2/repository/net/sourceforge/tess4j/tess4j/5.2.1/tess4j-5.2.1.jar .
jar uf tess4j-5.2.1.jar darwin
cp /usr/local/Cellar/tesseract/5.1.0/lib/libtesseract.5.dylib ./darwin/libtesseract.dylib
jar uf tess4j-5.2.1.jar darwin/libtesseract.dylib
4、将生成的tess4j