I have four packages:
com.spring.org
Files: HomeController.java
com.spring.org.dao
Files: SubscriberDao.java,SubscriberDaoImpl.java
com.spring.org.model
Files: Subscriber.java
com.spring.org.service
Files: SubscriberService.java,SubscriberServiceImpl.java
I put all my controller classes in com.spring.org and others in different packages based on its type. If I run my application, I get the following error message:
HTTP status 500 - Servlet.init () for the appServlet servlet throws an exception.
No qualified bean of type [com.spring.org.service.SubscriberService] found for the dependency was found: at least 1 bean is expected that qualifies as an auto-connect candidate for this dependency .....
FYI: , :
@Autowired
private SubscriberService subService;
com.spring.org, .
servlet-context.xml , :
<annotation-driven />
<context:annotation-config />
<context:component-scan base-package="com.spring.org.**" />
<context:component-scan base-package="com.spring.org.dao" />
<context:component-scan base-package="com.spring.org.model" />
<context:component-scan base-package="com.spring.org.service" />
:
<context:component-scan base-package="com.spring.org" />
servlet-context.xml http://postimg.org/image/s6bnjccrn/
, ?
, , .
Update
SubscriberService:
@Service
public interface SubscriberService {
public void addSubscriber(Subscriber subscriber);
public void updateSubscriber(Subscriber subscriber);
public Subscriber getSubscriberById(int subId);
public List<Subscriber> listSubs();
public int removeSubscriber(int subId);
}
org.springframework.beans.factory.BeanCreationException: bean "homeController": ; - org.springframework.beans.factory.BeanCreationException: autowire: private com.spring.service.SubscriberService com.spring.org.HomeController.subService; - org.springframework.beans.factory.NoSuchBeanDefinitionException: bean [com.spring.service.SubscriberService], : 1 bean, autwire . : {@org.springframework.beans.factory.annotation.Autowired(required = true), @org.springframework.beans.factory.annotation.Qualifier(value =)} org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues (AutowiredAnnotationBeanPostProcessor.java:292)
, , https://www.mediafire.com/?crxe7vt7uwyqwtl. Eclipse IDE.