简体   繁体   English

如何在同一个Java项目中获取mahout和neo4j?

[英]How to get mahout and neo4j in a same java project?

This is part of my pom.xml 这是我的pom.xml的一部分

<dependency>
    <groupId>org.apache.mahout</groupId>
    <artifactId>mahout-core</artifactId>
    <version>0.9</version>
</dependency>
<dependency>
    <groupId>org.apache.mahout</groupId>
    <artifactId>mahout-math</artifactId>
    <version>0.9</version>
</dependency>
<dependency>
     <groupId>org.neo4j</groupId>
     <artifactId>neo4j</artifactId>
     <version>2.2.1</version>
</dependency>

The ERROR is 错误是

Caused by: java.lang.ClassNotFoundException: org.apache.lucene.document.Fieldable
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

I found the mahout needs lucene-core 4.6.1, but the neo4j using neo4j-lucene-index 2.2.1, what can I do to solve this problem? 我发现mahout需要使用lucene-core 4.6.1,但是neo4j使用neo4j-lucene-index 2.2.1,我该怎么做才能解决此问题?

It's common problem. 这是普遍的问题。 Neo4j 2.3 uses old version of the Lucene (3.6.2). Neo4j 2.3使用旧版本的Lucene(3.6.2)。 In JVM you aren't able to use two different version of same library. 在JVM中,您不能使用同一库的两个不同版本。

You have few options how to deal with it, but you should not use them in the production. 您几乎没有选择如何处理它的方法,但是您不应在生产中使用它们。

  1. Create your own Class Loader. 创建自己的类加载器。

  2. Maven Shade plugin Maven Shade插件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM