1

我正在使用community orientdb 2.2.12. 当我在 IntelliJ 中运行应用程序时,一切正常。但是,当我编译项目时,出现以下错误:

Caused by: com.orientechnologies.orient.core.exception.OConfigurationException: Error on opening database: the engine 'remote' was not found. URL was: remote:xxxxxx/test1. Registered engines are: [memory, plocal]
    DB name="remote:xxxxxx/test1"
    at com.orientechnologies.orient.core.Orient.loadStorage(Orient.java:462)
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.<init>(ODatabaseDocumentTx.java:171)
    ... 13 more

聚甲醛:

        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-core</artifactId>
            <version>${orientdb-version}</version>
        </dependency>
        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-graphdb</artifactId>
            <version>${orientdb-version}</version>
        </dependency>
        <dependency>
            <groupId>com.tinkerpop.blueprints</groupId>
            <artifactId>blueprints-core</artifactId>
            <version>2.5.0</version>
        </dependency>
        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-client</artifactId>
            <version>${orientdb-version}</version>
        </dependency>
        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna-platform</artifactId>
            <version>4.0.0</version>
        </dependency>
        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <version>4.2.0</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.concurrentlinkedhashmap</groupId>
            <artifactId>concurrentlinkedhashmap-lru</artifactId>
            <version>1.4.2</version>
        </dependency>

我检查了阴影 JAR,它包含所有orientdb-client-*.

抛出异常的代码:

public OrientGraphFactory factory() {

    final int THREADS = Runtime.getRuntime().availableProcessors() + 1;

    return new OrientGraphFactory(
        AppConfig.getDatabaseConnectionString(),
        AppConfig.getDatabaseUsername(),
        AppConfig.getDatabaseSecret()).setupPool(THREADS, THREADS + 10);

}
4

1 回答 1

2

AFAIU 您正在尝试使用您的应用程序代码和 OrientDB 代码构建一个 uberJar。要包含正确的依赖项,我的建议是从分发 pom.xml 中复制列表:

https://github.com/orientechnologies/orientdb/blob/master/distribution/pom.xml

为什么它在 IntelliJ 中工作?好吧,IDE,甚至 Eclipse,都有一个类路径,其中包括测试源和测试 jar。当您使用 maven 构建时,它有一个“测试”类路径,与想法中的相同,以及一个没有测试 jar 的运行时类路径(并且没有测试 jar 的传递依赖!!!)。

关于远程连接,您需要一个正在运行的独立 OrientDB 服务器来连接,或者至少您的应用程序应该运行一个嵌入式服务器。

希望这有帮助。

于 2016-11-16T08:06:20.687 回答