Reputation: 1143
I want to develop basic create, read, update and delete functionality for a MySQL database that I have using Spring 4.1.1 and Hibernate 4.3.6. I am trying to use Telosys tools for the purpose but after I complete every step on the tutorial I get stuck with these errors during Tomcat startup.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dmsController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.mywebadmin.business.service.DMSService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)
...
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.mywebadmin.business.service.DMSService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:988)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:858)
...
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dmsController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.mywebadmin.business.service.DMSService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)
...
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.mywebadmin.business.service.DMSService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:988)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:858)
...
...
Here is the project structure that gets created after the tutorial.
How can I get this working, I looked for the implementations of the service interfaces it creates, but I couldn't find them in the whole project. Do I have to write them manually?
Upvotes: 1
Views: 1091
Reputation: 2460
No, there's nothing to write manually with Telosys Tools, but be careful there are 2 ways to generate a Spring MVC web app :
with the bundles for 'Spring MVC' + 'Spring Data' :
Bundles : 'front-springmvc' + 'service-springdatajpa' + 'persistence-springdatajpa'
with the bundles for 'Spring MVC' + 'JPA' (classical JPA without Spring Data) :
Bundles : 'front-springmvc' + 'service-jpa' + 'persistence-jpa'
Choose only one way and do not mix with other bundles.
Regarding the error it seems that Spring cannot found the implementation of your 'DMSService' interface. This implementation is generated by the 'service-xxx' bundle. By default the generated service classes are located in the package 'xxxx.business.service.impl' with a '@Component' annotation that allows Spring to use them. Check that (regenerate the 'service layer' if necessary)
You can also check the spring configuration files ( eg applicationContext.xml ) the 'component-scan base-package' must refer your package
Upvotes: 3