1org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactDao' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate collection role mapping com.mediaStorage.dto.Menu.userses
 2 at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
 3 at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
 4 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1244)
 5 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1008)
 6 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
 7 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
 8 at java.security.AccessController.doPrivileged(Native Method)
 9 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
10 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
11 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
12 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
13 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
14 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
15 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
16 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
17 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
18 at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
19 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
20 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
21 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
22 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334)
23 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
24 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
25 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
26 at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
27 at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
28 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
29 at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
30 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
31 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
32 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
33 at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
34 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
35 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
36 at org.apache.catalina.core.StandardService.start(StandardService.java:516)
37 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
38 at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
39 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
40 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
41 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
42 at java.lang.reflect.Method.invoke(Unknown Source)
43 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
44 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
45Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate collection role mapping com.mediaStorage.dto.Menu.userses
46 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1336)
47 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:471)
48 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
49 at java.security.AccessController.doPrivileged(Native Method)
50 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
51 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
52 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
53 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
54 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
55 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
56 at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
57  42 more
58Caused by: org.hibernate.DuplicateMappingException: Duplicate collection role mapping com.mediaStorage.dto.Menu.userses
59 at org.hibernate.cfg.Mappings.addCollection(Mappings.java:124)
60 at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2066)
61 at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2041)
62 at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:359)
63 at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:273)
64 at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:144)
65 at org.hibernate.cfg.Configuration.add(Configuration.java:669)
66 at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:504)
67 at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:631)
68 at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
69 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1367)
70 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1333)
71  52 more
72


 org.hibernate.DuplicateMappingException: Duplicate collection role mapping com.kinrich.mediaStorage.dto.Menu.userses
查资料发现这个错误是Menu里面的userses重复了  从Menu.java检查到Menu.hbm.xml 结果都没有发现错误,后面检查applicationContext.xml文件的mappingResources时发现我的有句value重复了  原来我是从那句开始是用的Ctrl+Alt往下复制的  后面做完没检查就出现了这个错误。  

下次选择用快捷键操作也要注意检查下是否正确。不然出了错误也就把快捷键省下的那点时间都浪费还有多。