有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java OrientDB服务器部分忽略OrientDB_HOME

我正在尝试启动一个嵌入式OrientDB服务器。我将ORIENTDB_HOME设置为包含config/plugins/文件夹的文件夹。我还将我的配置文件包括在类路径中,因为服务器似乎没有加载我的配置文件,即使它有默认名称

现在它确实启动并应用了我的配置,但是应用程序目录显然被用作ORIENTDB_HOME,因为我的插件没有加载,数据库是在那里创建的,而不是在我希望的地方创建的

这是我的代码:

public void startServer() {
    try {
        System.setProperty("ORIENTDB_HOME", "C:\\my\\orientdb_home\\path");

        server = OServerMain.create(true);
        // server.startup(); // this doesn't load the correct config
        server.startup(getClass().getResourceAsStream("/config/orientdb-server-config.xml")); // workaround
        server.activate();

        OServerNetworkListener httpListener = server.getListenerByProtocol(server.getNetworkProtocols().get("binary"));
        binaryPort = httpListener.getInboundAddr().getPort();
        httpListener = server.getListenerByProtocol(server.getNetworkProtocols().get("http"));
        httpPort = httpListener.getInboundAddr().getPort();

        System.out.println("Started OrientDB Server.\nBinary Port is " + binaryPort + "\nHTTP Port is " + httpPort);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

有趣的是,日志输出清楚地表明它正在为数据库使用正确的目录,但它没有这样做

2019-06-14 09:32:23:556 INFO  Loading configuration from input stream [OServerConfigurationLoaderXml]
2019-06-14 09:32:23:731 INFO  OrientDB Server v2.2.37 (build a7541e7ceeabf592dd9a7b2928b6c023cbc73193, branch 2.2.x) is starting up... [OServer]
2019-06-14 09:32:23:741 INFO  Databases directory: C:\my\orientdb_home\path\databases [OServer]
2019-06-14 09:32:23:830 INFO  Configuration of usage of soft references inside of containers of results of SQL execution [OMemoryAndLocalPaginatedEnginesInitializer]
2019-06-14 09:32:23:831 INFO  Initial or maximum values of heap memory usage are NOT set, containers of results of SQL executors will NOT use soft references by default [OMemoryAndLocalPaginatedEnginesInitializer]
2019-06-14 09:32:23:832 INFO  Auto configuration of disk cache size. [OMemoryAndLocalPaginatedEnginesInitializer]
2019-06-14 09:32:23:919 INFO  17066577920 B/16275 MB/15 GB of physical memory were detected on machine [ONative]
2019-06-14 09:32:23:919 INFO  Detected memory limit for current process is 17066577920 B/16275 MB/15 GB [ONative]
2019-06-14 09:32:23:921 INFO  OrientDB auto-config DISKCACHE=3,618MB (heap=3,618MB direct=3,618MB os=16,275MB) [OMemoryAndLocalPaginatedEnginesInitializer]
2019-06-14 09:32:23:922 INFO  Lowering disk cache size from 3,618MB to 3,616MB. [OGlobalConfiguration]
2019-06-14 09:32:24:117 INFO  Listening binary connections on 127.0.0.1:2424 (protocol v.36, socket=default) [OServerNetworkListener]
2019-06-14 09:32:24:120 INFO  Listening http connections on 127.0.0.1:2480 (protocol v.10, socket=default) [OServerNetworkListener]
2019-06-14 09:32:25:081 INFO  Storage 'plocal:databases/pvRelations' is created under OrientDB distribution : 2.2.37 (build a7541e7ceeabf592dd9a7b2928b6c023cbc73193, branch 2.2.x) [OLocalPaginatedStorage]
2019-06-14 09:32:27:607 INFO  {db=pvRelations} -> Loaded plocal database 'pvRelations' [OServer]
2019-06-14 09:32:27:609 INFO  Found ORIENTDB_ROOT_PASSWORD variable, using this value as root's password [OServer]
2019-06-14 09:32:27:621 INFO  ODefaultPasswordAuthenticator is active [ODefaultPasswordAuthenticator]
2019-06-14 09:32:27:623 INFO  OServerConfigAuthenticator is active [OServerConfigAuthenticator]
2019-06-14 09:32:27:625 INFO  OSystemUserAuthenticator is active [OSystemUserAuthenticator]
2019-06-14 09:32:27:634 INFO  Installed GREMLIN language v.2.6.0 - graph.pool.max=50 [OGraphServerHandler]
2019-06-14 09:32:27:638 WARNI Authenticated clients can execute any kind of code into the server by using the following allowed languages: [sql] [OServerSideScriptInterpreter]
2019-06-14 09:32:27:638 INFO  OrientDB Studio available at http://127.0.0.1:2480/studio/index.html [OServer]
2019-06-14 09:32:27:638 INFO  OrientDB Server is active v2.2.37 (build a7541e7ceeabf592dd9a7b2928b6c023cbc73193, branch 2.2.x). [OServer]

再次澄清:没有使用目录C:\my\orientdb_home\path\databases,而是path\to\my\application\databases

我做错了什么?我如何告诉服务器使用我选择的目录来搜索配置和插件以及存储数据库

编辑: 我刚刚注意到实际上使用了databases目录,但仅用于操作系统数据库。我自己的数据库存储在错误的位置。我在配置文件中定义了它:

...
<storages>
    <storage name="myDB" path="plocal:databases/myDB" userName="admin" userPassword="admin" loaded-at-startup="true" />
</storages>
...

编辑2: 所以我注意到,错误的数据库位置是由于配置文件中手动配置的存储路径造成的。然而,这仍然不能解释为什么我需要直接提供配置文件以及为什么我的插件(OrientDB Studio)没有加载


共 (1) 个答案

  1. # 1 楼答案

    事实证明,我应该读一下服务器。击球时要更加小心。虽然设置ORIENTDB_HOME显然会设置默认数据库目录,但默认配置文件不在%ORIENTDB_HOME%\config\orientdb-server-config.xml下。我必须设置环境变量orientdb.config.file

    我的插件没有加载,因为它不在plugins文件夹中,但被包含在我的类路径中,这显然是不够的