1
Spring MVC에서 오류가 있습니다.[service.NewsServiceImpl] 유형의 적격 빈이 정의되지 않았습니다.
Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [service.NewsServiceImpl] is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:373)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:333)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1088)
at controller.Testing.main(Testing.java:24)
NewsDAImpl 코드는 다음과 같습니다
@Repository
public class NewsDAImpl implements NewsDA {
@PersistenceContext
private EntityManager context;
@Override
public News ... Some Other Codes
내 NewsServiceImpl 클래스 :
@Service
@Transactional
public class NewsServiceImpl implements NewsService{
@Autowired
private NewsDAImpl newsDa;
@Override
public News ... Some Other Codes
내가 정적, 주요 무효 단지에 대한 테스트가 컨트롤러를 작성합니다.
다음ApplicationContext context = new AnnotationConfigApplicationContext(ProjectConfig.class);
난 그냥의 getBean 방법으로 뉴스 서비스를받을 :
NewsServiceImpl service = context.getBean(NewsServiceImpl.class);
어떻게'ProjectConfig'입니까? – ThomasEdwin
구현 코드를 작성하지 마십시오. 인터페이스 코드를 작성하십시오. 따라서 인터페이스 대신 DI를 사용하십시오. – SMA