내가 수행하고있는 것 : 스프링 애플리케이션 외부 JAR을 다른 비 스프링 애플리케이션에로드하고있다. 나는 이런 식으로 일을 해요 :이 내가받은 예외스프링 컨텍스트를 올바르게로드 할 수 없음
ApplicationContext ap = new ClassPathXmlApplicationContext("classpath:/META-INF/spring/application-context.xml");
MyService myService = (MyService) ap.getBean("myBusinessService");
:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myBusinessService': Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.test.domain.dao.MyDAO com.test.domain.service.impl.MyBusinessService.viaggioDAO; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.test.domain.dao.MyDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
패키지를 그 항아리 안에 것은 다음과 같습니다
- com.test.domain.service 서비스 용 인터페이스
- com.test.domain.services.impl f DAO 구현을위한 DAO 인터페이스 또는 서비스 구현
- com.test.domain.dao
- com.test.domain.dao.impl
질문 : 왜이를 수신하고 오류?
편집 : 내 앱에 대한 추가 정보
응용 프로그램의 context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- Spring IoC Context -->
<context:component-scan base-package="com.test" />
<import resource="root-config.xml" />
<import resource="classpath:/root-context.xml" />
<!-- Enables the Spring MVC @Controller programming model -->
<mvc:annotation-driven />
</beans>
MyBusinessService.java
@Service(value="myBusinessService")
public class MyBusinessService implements MyService {
@Autowired
private MyDAO myDAO;
@Override
public List<Stuff> getAllStuff() throws SQLException {
List<Stuff> stuff = this.myDAO.findAllStuff();
return stuff;
}
}
'@ Repository' 어노테이션이 DAO 인터페이스 또는 DAO 구현에 주어 졌는지 알려주십시오. – Mithun
DAO 구현에서 제공됩니다. 그리고 서비스 하나도 서비스 구현에 있습니다. – abierto
@abierto 당신은 우리와 함께 application-context.xml과 com.test.domain.service.impl.MyBusinessService.java 클래스를 공유 할 수 있습니까? – erhun