我从spring-data-neo4j 4.1版迁移到4.2版。
在应用程序启动时我收到错误:
Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.neo4j.ogm.session.Session' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
repository.ActivityRecordRepository.java:
public interface ActivityRecordRepository extends GraphRepository<ActivityRecord>, ActivityRecordRepositoryCustom {}
repository.ActivityRecordRepositoryCustom.java:
public interface ActivityRecordRepositoryCustom {
...
}
repository.impl.ActivityRecordRepositoryImpl.java:
public class ActivityRecordRepositoryImpl implements ActivityRecordRepositoryCustom {
private final Session session;
public ActivityRecordRepositoryImpl(Session session) {
this.session = session;
}
....
}
我的配置:
@ComponentScan
@Configuration
@EnableNeo4jRepositories("com.example.repository")
@EnableTransactionManagement
public class ApplicationConfiguration {
....
@Bean
public EventListener eventListener() {
return new CustomEventListener();
}
@Bean
public SessionFactory getSessionFactory() {
final SessionFactory sessionFactory = new SessionFactory(databaseConfiguration, "com.example.entity");
sessionFactory.register(eventListener());
return sessionFactory;
}
}
如何正确地将会话对象自动装配到自定义存储库实现?
我正在使用:
春季版:4.3.2.RELEASE
Spring Data Neo4j版本:4.2.11.RELEASE