我有以下连接到neo4j db的应用程序:
package graphdb;
import java.io.File;
import java.io.IOException;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.io.fs.FileUtils;
/**
*
* @author bma
*/
public class Graphdb {
private static final String DB_PATH = "D:\\Data";
public String greeting;
// START SNIPPET: vars
GraphDatabaseService graphDb;
Node firstNode;
Node secondNode;
Relationship relationship;
// END SNIPPET: vars
// START SNIPPET: createReltype
private static enum RelTypes implements RelationshipType
{
KNOWS
}
// END SNIPPET: createReltype
public static void main( final String[] args ) throws IOException
{
Graphdb hello = new Graphdb();
hello.createDb();
hello.removeData();
hello.shutDown();
}
void createDb() throws IOException
{
FileUtils.deleteRecursively( new File( DB_PATH ) );
// START SNIPPET: startDb
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase( DB_PATH );
registerShutdownHook( graphDb );
// END SNIPPET: startDb
// START SNIPPET: transaction
try ( Transaction tx = graphDb.beginTx() )
{
// Database operations go here
// END SNIPPET: transaction
// START SNIPPET: addData
firstNode = graphDb.createNode();
firstNode.setProperty( "message", "Hello, " );
secondNode = graphDb.createNode();
secondNode.setProperty( "message", "World!" );
relationship = firstNode.createRelationshipTo( secondNode, RelTypes.KNOWS );
relationship.setProperty( "message", "brave Neo4j " );
// END SNIPPET: addData
// START SNIPPET: readData
System.out.print( firstNode.getProperty( "message" ) );
System.out.print( relationship.getProperty( "message" ) );
System.out.print( secondNode.getProperty( "message" ) );
// END SNIPPET: readData
greeting = ( (String) firstNode.getProperty( "message" ) )
+ ( (String) relationship.getProperty( "message" ) )
+ ( (String) secondNode.getProperty( "message" ) );
// START SNIPPET: transaction
tx.success();
}
// END SNIPPET: transaction
}
void removeData()
{
try ( Transaction tx = graphDb.beginTx() )
{
// START SNIPPET: removingData
// let's remove the data
firstNode.getSingleRelationship( RelTypes.KNOWS, Direction.OUTGOING ).delete();
firstNode.delete();
secondNode.delete();
// END SNIPPET: removingData
tx.success();
}
}
void shutDown()
{
System.out.println();
System.out.println( "Shutting down database ..." );
// START SNIPPET: shutdownServer
graphDb.shutdown();
// END SNIPPET: shutdownServer
}
// START SNIPPET: shutdownHook
private static void registerShutdownHook( final GraphDatabaseService graphDb )
{
// Registers a shutdown hook for the Neo4j instance so that it
// shuts down nicely when the VM exits (even if you "Ctrl-C" the
// running application).
Runtime.getRuntime().addShutdownHook( new Thread()
{
@Override
public void run()
{
graphDb.shutdown();
}
} );
}
}
当我尝试编译时,我得到了以下错误msg:
run:
Exception in thread "main" java.lang.NoClassDefFoundError: org/neo4j/function/Function
at org.neo4j.graphdb.factory.GraphDatabaseFactory.createGraphDatabaseBuilder(GraphDatabaseFactory.java:99)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabaseBuilder(GraphDatabaseFactory.java:92)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:76)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:71)
at graphdb.Graphdb.createDb(Graphdb.java:57)
at graphdb.Graphdb.main(Graphdb.java:47)
Caused by: java.lang.ClassNotFoundException: org.neo4j.function.Function
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)
... 6 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
我做错了什么?如图所示,添加了neo4j库。
似乎必须将库org.neo4j.graphdb添加到类路径中。
可能是jar neo4j-kernel-2.2.2。罐子
或者,如果您使用的是maven,请添加工件:
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>2.2.2</version>
</dependency>
在创建hello world程序时,我遇到了这个异常。代码如下: 建造。渐变依赖项如下所示: 完整的stacktrace是这样的(我认为第一行是完全不相关的,但要确保):
我正在尝试编译并运行以下类: 我使用以下方法编译它: 但当我试图运行它时,我会遇到一个异常: java主 线程“main”java中出现异常。lang.NoClassDefFoundError:org/dom4j/io/SAXReader位于Main。main(main.java:31)由:java引起。lang.ClassNotFoundException:org。dom4j。木卫一。java的
我已经在我的pom.xml中添加了最新的硒依赖项 我用pom在目录中运行了mvn clean install。xml和我还根据Selenium文档在我的应用程序类中导入了正确的类 然而,当我尝试运行我的主方法时,我得到以下错误 我在我的~/. m2/repository文件夹中查看,我没有看到openqa文件夹,而是看到了seleniumhq文件夹。 为什么maven没有安装openqa文件夹,为
我知道有很多关于这个例外的帖子,但是我不能解决这个问题。我认为必须编辑类路径来解决它。我试图在hadoop架构体系中运行一个名为远程地图的程序。这是我得到的错误。 Echo$CLASSPATH给出了一个空行 cat~/。bash_简介说 更新: $HADOOP_HOME $HADOOP_CLASSPATH 有人能帮我解决这个问题吗? 谢谢
jar-cvfe-dhj。jar DefaultHadoopJobDriver 我的Hadoop作业只有一个类“DefaultHoopJobDrive”,它扩展了配置和实现工具,并将方法作为作业创建和inputpath、outpurpath集的唯一代码运行。我也在使用新的API。
我正在通过selenium学习自动化测试教程,并且正在用java语言编写我的第一个脚本,并且在Eclipse的“控制台”中得到了这条消息。 我的代码: 教程链接:http://toolsqa.wpengine.com/selenium-webdriver/first-test-case/