Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

本地跑没问题,但是Neo4j部署在服务器上会出现连接问题建议补上如下代码 #4

Open
tabular-rasa opened this issue Dec 1, 2022 · 2 comments

Comments

@tabular-rasa
Copy link

`import org.neo4j.ogm.session.SessionFactory;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.transaction.Neo4jTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**

  • @author : yuting.hu

  • @Date : 2022/12/1 9:35
    */
    @configuration
    @EnableNeo4jRepositories(basePackages = "com.appleyk.repository")// 开启Neo4jRepositories的支持
    @EntityScan(basePackages = "com.appleyk.model")// 开启实体类扫描
    @EnableTransactionManagement // 开启事务
    public class Neo4jConfig {
    @bean
    public SessionFactory sessionFactory() {
    // with domain entity base package(s)
    return new SessionFactory(configuration(), "com.appleyk.model");
    }

    @bean
    public org.neo4j.ogm.config.Configuration configuration() {
    //配置Neo4j连接
    return new org.neo4j.ogm.config.Configuration.Builder()
    .uri("bolt://xxx.xxx.xxx.xxx:7687").credentials("neo4j", "xxxxx").build();
    }

    @bean
    public Neo4jTransactionManager transactionManager() {
    return new Neo4jTransactionManager(sessionFactory());
    }
    }
    `
    如果不加如下代码 neo4j的配置可能读不到yaml而是直接默认localhost:7687

@Freecloudy
Copy link

{QU2 4QM9QWDISX@O72L
你好,我运行完之后出现这种情况与你说的一样吗?

@Dawn-create
Copy link

{QU2 4QM9QWDISX@O72L 你好,我运行完之后出现这种情况与你说的一样吗?

请问你解决了吗,我一直提示无法创建数据库实例:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants