为什么春季靴找不到我的豆子? [英] Why is spring boot not finding my beans?
问题描述
我有以下错误:
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..
此时的界面只是:
@Component
public interface ComposeCounterService {
CLASSX init(List<YYY> owners) throws JAXBException;
}
和隐含服务如下,并且在这种情况下,包含init()方法.
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
}
和ApplicationConfig文件位于服务包上方一层.在这篇文章中标记为xxx.
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"})
并且在.service之后没有composeXML 这些都不起作用.
and without the composeXML after .service None of these works.
我很确定我在这里遗漏了一些东西,请发送帮助.
im pretty sure im missing something here, please send help.
注射方式:
private final ComposeCounterService composeCounterService;
public ControlService(ComposeCounterService composeCounterService) {
this.composeCounterService = composeCounterService;
}
推荐答案
错误的导入是:
import org.jvnet.hk2.annotations.Service;
正确的是:
import org.springframework.stereotype.Service;
如果仅让您的IDE建议导入,然后按Enter键而不阅读添加的内容,那么结果就是这样.
If you just let your IDE suggest the import and press enter without reading which one it adds, this is the result.
这篇关于为什么春季靴找不到我的豆子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!