Issue
i have following error:
Parameter 0 of constructor in com.yyy.zzz.xxx.service.ControlService required a bean of type 'com.yyy.zzz.xxx.service.composeXML.ComposeCounterService' that could not be found.
Usually this is because i forget to annotate either the Service or the interface, but i've been looking classes the whole morning and cant find any missing annotations..
interface at this point is just:
@Component
public interface ComposeCounterService {
CLASSX init(List<YYY> owners) throws JAXBException;
}
and implimenting service is as follows, and contains init() method if that matters in this case.
@Service
public class ComposeCounterImpl implements ComposeCounterService {
/*** loots of code
}
and ApplicationConfig file is located one level above the service package. marked xxx in this post.
It contains the following package scan:
@SpringBootApplication
scanBasePackages = {"com.yyy.zzz.xxx")
i also tried it with array of scans like:
scanBasePackages = {"com.yyy.zzz.xxx", "com.yyy.zzz.xxx.service.composeXML"})
and without the composeXML after .service None of these works.
im pretty sure im missing something here, please send help.
EDIT: injecting style:
private final ComposeCounterService composeCounterService;
public ControlService(ComposeCounterService composeCounterService) {
this.composeCounterService = composeCounterService;
}
Solution
the wrong import is:
import org.jvnet.hk2.annotations.Service;
correct is:
import org.springframework.stereotype.Service;
If you just let your IDE suggest the import and press enter without reading which one it adds, this is the result.
Answered By - Repe