一、进入依赖库
<dependencies> <dependency> <groupId>com.hankcs</groupId> <artifactId>hanlp</artifactId> <version>portable-1.7.8</version> </dependency> </dependencies>
二、复制配置文件
1.打开命令行
(iterhui-hanlp) C:\Users\76709>hanlp -v jar 1.7.8: d:\anaconda3\envs\iterhui-hanlp\lib\site-packages\pyhanlp\static\hanlp-1.7.8.jar data 1.7.8: d:\anaconda3\envs\iterhui-hanlp\lib\site-packages\pyhanlp\static\data config : d:\anaconda3\envs\iterhui-hanlp\lib\site-packages\pyhanlp\static\hanlp.properties
2.复制hanlp.properties这个文件到src/main/resource下
demo来一个
public class Demo { public static void main(String args[]){ System.out.println(HanLP.segment("你好,欢迎使用Hanlp汉语处理包 ")); } }
得到结果: