试图嵌入存在db的问题 [英] Problems attempting to embed exist-db

查看:162
本文介绍了试图嵌入存在db的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用程序中使用exists-db,所以为了测试嵌入它,我按照eXist-db webppage上指定的指南 http://www.exist-db.org/exist/apps/doc/deployment.xml
对于有问题的代码本身:

I am trying to use exist-db in my application, so to test embedding it, i followed the guide specified on the eXist-db webppage http://www.exist-db.org/exist/apps/doc/deployment.xml. For the code in question itself:

import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.Database;
import org.exist.xmldb.DatabaseInstanceManager;
public class TestDB {       
    public static void main(String args[]) throws Exception {
        // initialize driver
        Class cl = Class.forName("org.exist.xmldb.DatabaseImpl");
        Database database = (Database)cl.newInstance();
        database.setProperty("create-database", "true");
        DatabaseManager.registerDatabase(database);

        // try to read collection
        Collection col = 
            DatabaseManager.getCollection("xmldb:exist:///db", "admin", "");
        String resources[] = col.listResources();
        System.out.println("Resources:");
        for (int i = 0; i < resources.length; i++) {
            System.out.println(resources[i]);
        }

        // shut down the database
        DatabaseInstanceManager manager = (DatabaseInstanceManager) 
            col.getService("DatabaseInstanceManager", "1.0"); 
        manager.shutdown();
    }
}

代码本身可以在网页底部找到我提供。
这最终导致卡在执行 DatabaseManager.getCollection(xmldb:exist:/// db,admin,)以下输出 https://pastebin.com/b6Tf7K1L

Code itself can be found at the bottom of the webppage i provided. This ended up getting stuck on the execution of DatabaseManager.getCollection("xmldb:exist:///db", "admin", "") with the following output https://pastebin.com/b6Tf7K1L .

我选择的VM选项是 -Djava.endorsed.dirs = lib / endorsed -Dexist.initdb = true -Dexist.home =。(使用2017.2.7 IntelliJ IDEA和Java 8)。

The VM options i chose were -Djava.endorsed.dirs=lib/endorsed -Dexist.initdb=true -Dexist.home=. (using 2017.2.7 IntelliJ IDEA and Java 8).

这是我第一次使用exists-db和xml数据库,并且无法找到解决方案。我在上面提供的链接中遵循了指南中的在应用程序中嵌入eXist部分。

This is the first time i am working with both exist-db and xml databases in general, and have can't figure out the solution. I have followed the "Embedding eXist in an Application" part of the guide in above provided link.

推荐答案

因此,从您的输出中,您缺少类路径中的一些jar文件。避免此类事情的最佳方法是使用Maven作为构建系统并使用我们在github.com/exist-db/mvn-repo上发布的Maven工件

So from your output you are missing some jar files from your classpath. The best way to avoid such things is likely to use Maven as your build system and use our Maven artifacts published at github.com/exist-db/mvn-repo

你如果你想使用更方便的ExistEmbeddedServer类,可能希望从依赖于exists-core和可能存在的testkit开始。

You probably want to start with a dependency on exist-core and possibly exist-testkit if you want to use the more convenient ExistEmbeddedServer class.

对于缺乏细节的道歉,我这几天我的手机只有我。

Apologies for the lack of detail, I only have my phone with me these last few days.

ps您还可以在此处找到从eXist本书中为您自己的eXist-db项目使用Maven的代码示例 - https://github.com/exist-book/book-code 。当这本书出版时,它们适用于eXist 2.1。我还在这里更新了eXist-db 4.0.0的代码 - https://github.com/eXist-book/book-code/tree/eXist-4.0.0

p.s. you can also find code examples of using Maven for your own eXist-db projects from the eXist book here - https://github.com/exist-book/book-code. They are for eXist 2.1 as the book was published then. I have also updated the code for eXist-db 4.0.0 here - https://github.com/eXist-book/book-code/tree/eXist-4.0.0.

这篇关于试图嵌入存在db的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆