使用GWT连接到Spring和Hibernate服务

时间:2011-06-20 20:36:41

标签: hibernate spring gwt

我正在尝试使用GWT,Spring,Hibernate和MySQL建立一个环境。我有GWT和spring设置为服务器生成RPC并返回消息。但是我在连接数据库时遇到了一些麻烦。已经设置了一个服务来连接数据库以检索数据,但我正在尝试连接到该服务以检索数据。所以这是一个总体布局:

MyService - > UserService - >数据库

执行期间出现以下错误。

00:00:00.003 [WARN] Nested in org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mobiquitousUserService' defined in file [C:\Users\Yan\Desktop\Project\Workspace\MobiquitousPresentation\war\WEB-INF\classes\com\mobiquitous\presentation\server\MobiquitousUserSerivceImpl.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [com.mobiquitous.data.services.common.UserService]: : No matching bean of type [com.mobiquitous.data.services.common.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=userService)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.mobiquitous.data.services.common.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=userService)}: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.mobiquitous.data.services.common.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=userService)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:914) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:783) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:697) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:784) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:711) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:194) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:993) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:897) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:574) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:543) at org.mortbay.jetty.servlet.Context.startContext(Context.java:136) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448) at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:463) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) at org.mortbay.jetty.Server.doStart(Server.java:222) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:667) at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:500) at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1055) at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:804) at com.google.gwt.dev.DevMode.main(DevMode.java:309)

有人可以告诉我这意味着什么吗?

1 个答案:

答案 0 :(得分:0)

您尝试在mobiquitousUserService构造函数中注入的UserService似乎未在Spring上下文中声明

确保您使用

注释了UserService
org.springframework.stereotype.Service

注释,并使用

设置Spring配置
<context:annotation-config />