In Spring, how do I invoke a public method from an autowired bean, in which the method is not part of the interface?
Date : March 29 2020, 07:55 AM
it helps some times Create a new Interface extending UserDetailsService and add your desired method. public class MyUserDetailsService extends UserDetailsService {
...
public SpringboardAuthenticationUser getSpringboardAuthenticationUser(final User domainUser);
...
}
public class MyUserDetailsServiceImpl implements MyUserDetailsService {
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
}
@Override
public SpringboardAuthenticationUser getSpringboardAuthenticationUser(final User domainUser){
...
//Your logic here.
}
}
private MyUserDetailsService userDetailsService;
|
When a SubClass which is a spring bean calls method of SuperClass which is also a spring bean, the autowired field in Su
Date : March 29 2020, 07:55 AM
Does that help Because you might not have any Inheritance in your Bean Definition. Super-class members, loaded into memory during creation of respective child-class according to the Java OOP model, is not going to be referencing your explicit Spring Bean. I. E. you have Java inheritance, but you should also define Bean Inheritance, if you'd want to achieve what you ask in your question. Otherwise, your explicit component is not necessarily the one where your "child" component inherits from. This is also the answer for your
|
Can I use @Autowired variable in @Bean method?
Date : March 29 2020, 07:55 AM
|
Spring @Bean method executing after @Autowired
Date : March 29 2020, 07:55 AM
|
A method with @Bean autowires without @Autowired
Tag : java , By : Habikki
Date : March 29 2020, 07:55 AM
|