我想为使用Spring 4.1.1和Hibernate 4.3.6的MySQL数据库开发基本的创建,读取,更新和删除功能。 我正在尝试使用Telosys tools,但在完成tutorial的每一步后,我在Tomcat启动期间遇到了这些错误。
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)
...
...
这是在教程之后创建的项目结构。
我怎样才能使这个工作,我寻找的实现 它创建的服务接口,但我无法在整体中找到它们 项目。我必须手动编写吗?
答案 0 :(得分:3)
不,没有什么可以用Telosys Tools手动编写,但要小心有两种方法来生成Spring MVC Web应用程序:
带有Spring MVC'的捆绑包+' Spring Data' :
捆绑:' front-springmvc' +' service-springdatajpa' +' persistence-springdatajpa'
带有Spring MVC'的捆绑包+' JPA' (没有Spring Data的经典JPA):
捆绑:' front-springmvc' +' service-jpa' +' persistence-jpa'
只选择一种方式,不要与其他捆绑包混用。
关于错误,Spring似乎无法找到您的“DMS服务”的实现。接口。此实施由' service-xxx '生成。束。 默认情况下,生成的服务类位于包“ xxxx.business.service.impl '使用' @Component '允许Spring使用它们的注释。检查(重新生成'服务层'必要时)
您还可以检查弹簧配置文件(例如applicationContext.xml) '组件扫描基础包'必须参考你的包裹