org.neo4j.kernel.StoreLockException:

报错信息:

Caused by: org.neo4j.kernel.StoreLockException: Store and its lock file has been locked by another process: D:\neo4j-com

 产生异常的原因是,以内嵌方式连接的话,一个库应该是只能有一个连接

而在cmd 中以下面的命令启动neo4j时

neo4j.bat console

79108bf2c92c7aa1a24bd0cf1251d6b6ff4.jpg

neo4j 自己带的web应用就连上了默认的数据库,“data/databases/graph.db”。

 

所以我们要以 HTTP的形式连接

 

我这里用的是SpringData neo4j连接的,连接配置方下面

/**
 * Spring JavaConfig configuration class to setup a Spring container and infrastructure components.
 */
@Configuration
@EnableNeo4jRepositories(basePackages = "org.jsg.dao") // 我们操作数据的包名
@EnableTransactionManagement
public class GraphDBConfiguration extends Neo4jConfiguration {


   @Bean
   public org.neo4j.ogm.config.Configuration getConfiguration() {
      org.neo4j.ogm.config.Configuration config =
               new org.neo4j.ogm.config.Configuration();

      /** 以内嵌的方式连接 **/
     /* config.driverConfiguration()
            .setDriverClassName("org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver") // 驱动名
            .setURI("file:/D:/neo4j-community-3.4.5/data/databases/graph.db"); // 要连接数据库所在位置*/

      /** 以HTTP的方式连接 **/
      config.driverConfiguration()
              .setDriverClassName("org.neo4j.ogm.drivers.http.driver.HttpDriver") // 驱动名
              .setURI("http://neo4j:admin@localhost:7474"); // 以【http://用户名:密码@域名:端口】的形式
      return config;
   }


   @Override
   @Bean
   public SessionFactory getSessionFactory() {
      return new SessionFactory(getConfiguration(), "org.jsg.domain"); // 基础实体存在的包位置
   }
}

刚开始我用内嵌的方式死活连不了默认库,后来换HTTP的方式就行了

转载于:https://my.oschina.net/zjllovecode/blog/2051095

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值