Skip to content

Missing Neo4jTransactionManager after migrated from Spring Boot 2.7.3 to 3 #2657

@luan-cestari-trustly

Description

@luan-cestari-trustly

To solve the problem, we had to redefine it:


import org.neo4j.driver.Driver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.core.DatabaseSelectionProvider;
import org.springframework.data.neo4j.core.transaction.Neo4jBookmarkManager;
import org.springframework.data.neo4j.core.transaction.Neo4jTransactionManager;
import org.springframework.data.neo4j.repository.config.Neo4jRepositoryConfigurationExtension;

import java.util.Objects;

@Configuration
@SuppressWarnings("unused")
public class Neo4jTransactionConfiguration {

    @ConditionalOnMissingBean(name = Neo4jRepositoryConfigurationExtension.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME)
    @Bean(name = "transactionManager")
    public Neo4jTransactionManager neo4jTransactionManager(@Autowired Driver driver,
                                                           @Autowired DatabaseSelectionProvider databaseSelectionProvider,
                                                           @Autowired(required = false) Neo4jBookmarkManager neo4jBookmarkManager) {
        return new Neo4jTransactionManager(driver, databaseSelectionProvider,
                                           Objects.requireNonNullElseGet(neo4jBookmarkManager, Neo4jBookmarkManager::create));
    }
}

I opened this Issue to share the problem and help people with a workaround until this got fixed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions