You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code below was working before updating to Spring version 2.4.3 on version 2.3.5.RELEASE.
It's not possible anymore to inject a repository via constructor into a custom repository, otherwise you get a circular dependency error.
Which you do not get if you use field injection with @Autowired.
Is this maybe a regression or did something get changed that this is not possible anymore in the new version?
┌─────┐
| customUserRepositoryImpl defined in file [.../custom_repository/build/classes/kotlin/main/com/example/demo/CustomUserRepositoryImpl.class]
↑ ↓
| userRepository defined in com.example.demo.UserRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration
↑ ↓
| (inner bean)#31691525
↑ ↓
| customUserRepositoryImplFragment
└─────┘
The text was updated successfully, but these errors were encountered:
I think what you're experiencing here is a change in Spring Boot how JPA repositories are bootstrapped. Generally speaking, fragments are required at the time of constructing the actual repository. Therefore, you cannot inject a direct instance of the repository to be created into a fragment or a custom repository implementation. You can use @Lazy (proxying the bean) or a lookup via ApplicationContext or ObjectProvider.
The code below was working before updating to Spring version
2.4.3
on version2.3.5.RELEASE
.It's not possible anymore to inject a repository via constructor into a custom repository, otherwise you get a circular dependency error.
Which you do not get if you use field injection with
@Autowired
.Is this maybe a regression or did something get changed that this is not possible anymore in the new version?
The text was updated successfully, but these errors were encountered: