Is it possible to run database from Spring application

I am wondering if It's possible to start a Neo4J database directly from the Spring application. Right now, when I want to connect with my database I have to lauch Neo4J Desktop first and start a certain database so I can then connect it to my spring appliaction

This is the configuration class I use to connect wih the database

@EnableNeo4jRepositories(basePackages = "com.example.neo4j_example_1.repository")
public class Neo4jConfig {

    public SessionFactory sessionFactory() {
        return new SessionFactory(configuration(), "com.example.neo4j_example_1.model");

    public org.neo4j.ogm.config.Configuration configuration() {
        org.neo4j.ogm.config.Configuration configuration = new org.neo4j.ogm.config.Configuration.Builder()
                .credentials("neo4j", "neo4j")
        return configuration;

    public Neo4jTransactionManager transactionManager() {
        return new Neo4jTransactionManager(sessionFactory());


I'd like to start my database from Spring application without having to launch Neo4J Desktop before. Is that possible? I coudn't find a solution anywhere

Hi, I think that it is not possible. You must start neo4j before.


1 Like