Hi,

We moved from Spring Boot 2.7.3 to 3.0.1 and we also using Spring Data. After that, we noticed the Neo4jTransactionManager was missing, so any configuration like transaction timeout, was not working anymore

We made the follow code as workaround to solve the problem:

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 this workaround until this got fixed

Comment From: luan-cestari-trustly

PS: I opened the same issue to Spring Data Neo4J and they asked to open the issue here

Comment From: wilkinsona

As long as a org.springframework.transaction.TransactionManager hasn't already been defined, Neo4jDataAutoConfiguration should auto-configure a Neo4jTransactionManager. With only a little information about your application it's impossible for us to tell why that apparently isn't happening. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: luan-cestari-trustly

My colleague mentioned that exception was thrown or logged ( which is pretty bad ) and he saw no big change in the org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration :

    @Bean(Neo4jRepositoryConfigurationExtension.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME)
    @ConditionalOnMissingBean(TransactionManager.class)
    public Neo4jTransactionManager transactionManager(Driver driver, DatabaseSelectionProvider databaseNameProvider,
            ObjectProvider<TransactionManagerCustomizers> optionalCustomizers) {
        Neo4jTransactionManager transactionManager = new Neo4jTransactionManager(driver, databaseNameProvider);
        optionalCustomizers.ifAvailable((customizer) -> customizer.customize(transactionManager));
        return transactionManager;
    }

Comment From: wilkinsona

Thanks but a copy-paste of Boot's own code doesn't help us to understand why your application's behaving in the way that it is. Please provide the sample that I asked for above.

Comment From: luan-cestari-trustly

We found the root cause, another spring module added was also defining TransactionManager. Fixed. Thank you for your help