Я получаю исключение -получение «Определяющий компонент типа не определен».
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.muztaba.service.VerdictServiceImpl] is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:372)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:332)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1066)
at com.muztaba.service.App.task(App.java:35)
at com.muztaba.service.App.main(App.java:28)
Это класс, откуда я получаю там исключение.
@Component
public class App {
QueueService<Submission> queue;
Compiler compiler;
VerdictService verdictService;
public static void main(String[] args) {
new App().task();
}
private void task() {
AbstractApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
queue = context.getBean(QueueImpl.class);
compiler = context.getBean(CompilerImpl.class);
verdictService = context.getBean(VerdictServiceImpl.class); //here the exception thrown.
while (true) {
if (!queue.isEmpty()) {
Submission submission = queue.get();
compiler.submit(submission);
}
}
}
}
Первые две переменные, введенные должным образом, но вердиктСервис не является. это мой VerdictService
и VerdictServiceImpl
интерфейс и класс.
public interface VerdictService {
void post(Verdict verdict);
}
==
@Service
@Transactional
public class VerdictServiceImpl implements VerdictService {
@Autowired
SessionFactory sessionFactory;
@Override
public void post(Verdict verdict) {
sessionFactory.getCurrentSession()
.save(verdict);
}
}
и это мой класс конфигурации
@Configuration
@EnableScheduling
@ComponentScan(basePackages = "com.muztaba")
public class AppConfig {
}
Я даю структуру каталогов проекта.
Что я здесь отсутствует? Спасибо.
Ваш VerdictServiceImpl в "com.muztaba" или суб пакетов? – kuhajeyan
@kuhajeyan VerdictServiceImpl находится в пакете 'com.muztaba.service' – seal