概括
我正在使用 OrientDB 3.0.0,并且我正在尝试避免使用 ODatabaseDocumentTx 等已弃用的 API。但是,当我用 com.orientechnologies.orient.core.db.OrientDB 替换它时;对于其他工作正常的相同配置,它会爆炸。
详情如下...
配置
odb.url=memory:neurosys_orientdb_odb
odb.username=admin
odb.password=admin
odb.maxPartitionSize=2
odb.maxPoolSize=10
使用有效的 ODatabaseDocumentTx 的 Spring 配置
<bean id="dataSourceOdb" class="com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx" init-method="create">
<constructor-arg value = "${odb.url}"/>
</bean>
<bean id="connectionPoolDataSourceOdb" class="com.orientechnologies.orient.core.db.OPartitionedDatabasePool">
<constructor-arg value = "${odb.url}" index="0"/>
<constructor-arg value = "${odb.username}" index="1"/>
<constructor-arg value = "${odb.password}" index="2"/>
<constructor-arg value = "${odb.maxPartitionSize}" index="3"/>
<constructor-arg value = "${odb.maxPoolSize}" index="4"/>
</bean>
春天CONFIGS使用com.orientechnologies.orient.core.db.OrientDB,做不工作
只需更换dataSourceOdb
豆子。
<bean id="dataSourceOdbNew" class="com.orientechnologies.orient.core.db.OrientDB">
<constructor-arg value = "${odb.url}"/>
<constructor-arg value = "${odb.username}" />
<constructor-arg value = "${odb.password}" />
<constructor-arg><null /></constructor-arg>
抛出异常
com.orientechnologies.orient.core.exception.ODatabaseException:无法在 com.orientechnologies.orient.core.db.OrientDBEmbedded.open (OrientDBEmbedded.java:140) 在 com.orientechnologies.orient.core.db 打开数据库'neurosys_orientdb_odb'。 document.ODatabaseDocumentTx.open (ODatabaseDocumentTx.java:908) at com.orientechnologies.orient.core.db.OPartitionedDatabasePool $ DatabaseDocumentTxPooled.internalOpen (OPartitionedDatabasePool.java:441) at com.oritionPoolDab.D. OPartitioned:com30Pool.java .orientechnologies.orient.core.db.OPartitionedDatabasePool.acquire (OPartitionedDatabasePool.java:261) ... at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (RemoteTestRunner.jain: 192) 由:com. orienttechnologies.orient.core.exception.OStorageException:无法打开存储“neurosys_orientdb_odb”,因为它不存在于 com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.open(OAbstractPaginatedStorage.java:267) 的路径中:D:\orientdb./neurosys_orientdb_odb。 orientechnologies.orient.core.db.OrientDBEmbedded.open(OrientDBEmbedded.java:131) ... 34 更多
可能的原因假设一个 Unix 约定路径,即使对于内存数据库,路径看起来也很混乱。我在 Windows 上,但我不明白为什么这对内存数据库很重要。此外,它适用于已弃用的 API,所以我认为这是一个错误。如果没有,请让我知道我缺少什么。
我通过使区别开来解决我的问题url
,并database
和不包含在URL中的数据库。
然后使事情 1 步 IOC 友好;写了一个返回的工厂pool
OrientDB odb = new OrientDB(url, OrientDBConfig.defaultConfig());
odb.createIfNotExists(database, odbType==null?ODatabaseType.MEMORY:odbType);
OrientDBConfig config = OrientDBConfig.builder().build(); //... configBuilder.addConfig(OGlobalConfiguration key, value);
ODatabasePool pool = new ODatabasePool(odb, database, username, password, config);
配置现在在哪里:(orientdb&see https://orientdb.com/docs/2.1.x/Configuration.html)
odb.url=memory:
odb.database=neurosys_orientdb_odb
odb.username=admin
odb.password=admin
odb.pool.min=1
odb.pool.max=5
注意:上述配置是针对应用程序自定义的,但映射到一个OGlobalConfiguration
常量
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句