In addition to a non-reactive JPA repository, I introduced a reactive repository in my Spring Boot app with H2 database.
com.app.respository.BusinessRepository extends JpaRepository
com.app.respository.r2dbc.PendingBusinessRepository extends ReactiveCrudRepository
And I added a connection factory for reactive H2.
@Configuration
@EnableR2dbcRepositories
public class R2DBCConfiguration extends AbstractR2dbcConfiguration {
@Bean
public H2ConnectionFactory connectionFactory() {
return new H2ConnectionFactory(
H2ConnectionConfiguration.builder()
.url("jdbc:h2:file:~/data/demo-rxdb")
.username("sa")
.password("password")
.build());
}
}
After this change, my application is not able to find the non-reactive repository. It says:
Field businessRepository in com.app.service.BusinessServiceImpl required a bean of type 'com.app.repository.BusinessRepository' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'com.app.repository.BusinessRepository' in your configuration.
I can only guess that maybe my H2 database is now reactive (non-blocking) which is not supported by a JPARepository (blocking). But is my assumption correct?
I have mixed needs. I need only PendingBusiness
table data in a non-blocking way (which is constantly being fluxed out on UI through event stream) and I need the rest of the tables' data in a traditional blocking way. Is it possible to achieve what I want through a single H2 database instance?