我使用Spring数据图为Neo4J构建了一个新项目。我正在使用Maven。
嵌入式数据库的一切正常,但是当我尝试使用REST在远程服务器上设置数据库时,我得到了:
java.lang.ClassNotFoundException: org.springframework.data.neo4j.rest.SpringRestGraphDatabase
我在大约一年前看过一个post,但没有解决方案 - 至少没有一个对我有用......在这篇文章中他们提到了我确实使用的aspectJ。
有人熟悉这个吗?有没有人有一个工作配置示例?
我真的尝试了不同配置的L-O-T,基于不同论坛和指南中的不同帖子。这是我的最后一个 - 我只是指定我还有其他POM,所有这些POM都由父POM分组(这是一个错误项目)。
这是bean的定义:
<!-- Neo4j configuration (creates Neo4jTemplate) -->
<datagraph:config graphDatabaseService="neo4JRestGraphDatabase" />
<!-- With this uncommented - it works great -->
<!--datagraph:config storeDirectory="data/graph.db" /-->
这是该项目的POM:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.vo.insight</groupId>
<artifactId>content-insights-model-processed</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>content-insights-model-processed</name>
<url>http://maven.apache.org</url>
<parent>
<artifactId>content-insights-parent</artifactId>
<groupId>com.vo.insight</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../content-insights-parent/pom.xml</relativePath>
</parent>
<properties>
<neo4j-rest-graphdb.version>2.0.0-M06</neo4j-rest-graphdb.version>
<neo4j.version>1.8.M06</neo4j.version>
</properties>
<dependencies>
<dependency>
<groupId>com.vo.insight</groupId>
<artifactId>content-insights-common</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Neo4J -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>3.0.0.BUILD-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-rest-graphdb</artifactId>
<version>${neo4j-rest-graphdb.version}</version>
<exclusions>
<exclusion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
</exclusion>
<exclusion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-lucene-index</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<version>${neo4j.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
</exclusion>
<exclusion>
<groupId>de.huxhorn.lilith</groupId>
<artifactId>de.huxhorn.lilith.3rdparty.rrd4j</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.main</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.fileinstall</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Do not remove this although we are not using Hibernate! this is needed
for Neo4J -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<!-- Cassandra Client -->
<dependency>
<groupId>me.prettyprint</groupId>
<artifactId>hector-core</artifactId>
</dependency>
<dependency>
<groupId>me.prettyprint</groupId>
<artifactId>hector-object-mapper</artifactId>
<version>3.0-04</version>
</dependency>
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-all</artifactId>
</dependency>
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
</dependency>
</dependencies>
<build>
</build>
<!-- this profile is for ci build mode. to activate it use -Pci flag -->
<profiles>
<profile>
<id>ci</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<outxml>true</outxml>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
<aspectLibrary>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
</aspectLibrary>
</aspectLibraries>
<source>1.6</source>
<target>1.6</target>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
感谢您的帮助!
卡梅尔
答案 0 :(得分:4)
如果您使用Spring Data,我认为您不想使用“org.neo4j”依赖项。我不是专家,但我目前的项目仅适用于:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>${org.springframework.data-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j-rest</artifactId>
<version>${org.springframework.data-version}</version>
</dependency>
答案 1 :(得分:1)
我认为您需要包含org.springframework.data.spring-data-neo4j-rest
工件,而不仅仅是org.neo4j.neo4j-rest-graph-db
。
此外,你正在非常自由地混合版本
我不知道SDN 3的相关依赖性和兼容性,并且将它混合起来并不一定有任何问题,但如果你用pom得到ClassNotFoundException
或NoClassDefFoundError
像这样,您可能希望查看您的依赖关系树,例如在项目根目录中运行mvn dependency:tree -Dverbose
,以查看是否存在冲突版本导致某些依赖项被静默排除。
答案 2 :(得分:0)
最后,问题是我的neo4JRestGraphDatabase的定义(遗憾的是我还没有粘贴在这里......)。
是:
<bean id="graphDatabaseService" class="org.springframework.data.neo4j.rest.RestGraphDatabase">
<constructor-arg value="http://localhost:7474/db/data/" />
</bean>
而不是:
<bean id="graphDatabaseService" class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
<constructor-arg value="http://localhost:7474/db/data/" />
</bean>
现在我有'拒绝连接'问题,但这是another issue。
关于依赖关系,上面提到的依赖关系确实足够了。
感谢任何想要帮助的人!
卡梅尔