I need to introduce @Autouired specific implementation of a class of service.
Service Interface:
public interface PostService { ... }
Implementation:
@Service("postServiceImpl") public class PostServiceImpl implements PostService { ... }
Methods in the service: @Transactional annotation
And now I want to add postServiceImpl to my controller, because I need to use one method from the implementation that is missing from the interface:
@Autowired @Qualifier("postServiceImpl") private PostServiceImpl postService;
I get a NoSuchBeanDefinitionException with the following message:
There is no qualification bean of the type [(...). PostServiceImpl] found for the dependency: at least 1 bean is expected that qualifies as an autowire candidate for this dependency.
when I change the field in my controller to:
private PostService postService
It works, but I cannot use a specific method from PostServiceImpl.
java spring dependency-injection service autowired
tomdavies
source share