最代码官方的gravatar头像
最代码官方 2017-06-04 19:49:17

为什么apache lucene在命令行下执行java代码时无法加载到自定义的扩展词库?

解决大半天没有找到原因,估计是java class path的路径问题

通过一种比较笨的办法暂时解决了

java -classpath "/data/www/search.zuidaima.com/WEB-INF/classes/:/data/maven/repo/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar:/data/maven/repo/mysql/mysql-connector-java/5.1.9/mysql-connector-java-5.1.9.jar:/data/maven/repo/org/springframework/spring-web/4.1.1.RELEASE/spring-web-4.1.1.RELEASE.jar:/data/maven/repo/org/springframework/spring-aop/4.1.1.RELEASE/spring-aop-4.1.1.RELEASE.jar:/data/maven/repo/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/data/maven/repo/org/springframework/spring-beans/4.1.1.RELEASE/spring-beans-4.1.1.RELEASE.jar:/data/maven/repo/org/springframework/spring-core/4.1.1.RELEASE/spring-core-4.1.1.RELEASE.jar:/data/maven/repo/org/springframework/spring-context/4.1.1.RELEASE/spring-context-4.1.1.RELEASE.jar:/data/maven/repo/org/springframework/spring-expression/4.1.1.RELEASE/spring-expression-4.1.1.RELEASE.jar:/data/maven/repo/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar:/data/maven/repo/org/springframework/spring-webmvc/4.1.1.RELEASE/spring-webmvc-4.1.1.RELEASE.jar:/data/maven/repo/com/zuidaima/javaniu_search_common/0.0.1-SNAPSHOT/javaniu_search_common-0.0.1-SNAPSHOT.jar:/data/maven/repo/com/caucho/hessian/4.0.38/hessian-4.0.38.jar:/data/maven/repo/junit/junit/4.10/junit-4.10.jar:/data/maven/repo/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar:/data/maven/repo/org/springframework/spring-tx/4.1.1.RELEASE/spring-tx-4.1.1.RELEASE.jar:/data/maven/repo/org/springframework/spring-test/4.1.1.RELEASE/spring-test-4.1.1.RELEASE.jar:/data/maven/repo/org/springframework/spring-context-support/4.1.1.RELEASE/spring-context-support-4.1.1.RELEASE.jar:/data/maven/repo/log4j/log4j/1.2.17/log4j-1.2.17.jar:/data/maven/repo/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.jar:/data/maven/repo/org/aspectj/aspectjweaver/1.6.12.RELEASE/aspectjweaver-1.6.12.RELEASE.jar:/data/maven/repo/org/ini4j/ini4j/0.5.1/ini4j-0.5.1.jar:/data/maven/repo/org/apache/lucene/lucene-core/4.10.0/lucene-core-4.10.0.jar:/data/maven/repo/org/apache/lucene/lucene-queryparser/4.10.0/lucene-queryparser-4.10.0.jar:/data/maven/repo/org/apache/lucene/lucene-queries/4.10.0/lucene-queries-4.10.0.jar:/data/maven/repo/org/apache/lucene/lucene-sandbox/4.10.0/lucene-sandbox-4.10.0.jar:/data/maven/repo/org/wltea/analyzer/lucene/IKAnalyzer/5.0.1/IKAnalyzer-5.0.1.jar:/data/maven/repo/org/databene/contiperf/2.2.0/contiperf-2.2.0.jar:/data/maven/repo/com/fasterxml/jackson/core/jackson-core/2.4.3/jackson-core-2.4.3.jar:/data/maven/repo/com/fasterxml/jackson/core/jackson-databind/2.4.3/jackson-databind-2.4.3.jar:/data/maven/repo/com/fasterxml/jackson/core/jackson-annotations/2.4.0/jackson-annotations-2.4.0.jar" com.zuidaima.script.LuceneInit

将所有加载的jar包都放到classpath中

D:\>java -Djava.ext.dirs=D:/workspace_idea/javaniu_search/target/javaniu_search-1.0/WEB-INF/lib/ -classpath D:/workspace_idea/javaniu_search/target/javaniu_search-1.0/WEB-INF/classes/ com.zuidaima.script.LuceneInit

为什么apache lucene在命令行下执行java代码时无法加载到自定义的扩展词库?

正常的

为什么apache lucene在命令行下执行java代码时无法加载到自定义的扩展词库?

项目截图

为什么apache lucene在命令行下执行java代码时无法加载到自定义的扩展词库?

 

有没有更简单的办法吗?

所有回答列表(0)
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友