2015-04-17 53 views
-3

創造豆我不知道AHY我得到這個錯誤時,我想使用Spring bean的這個主要測試測試我的應用程序: 公共類的測試{錯誤名爲「道」

public static void main(String[] args) { 
    ClassPathXmlApplicationContext context= 
    new ClassPathXmlApplicationContext(new String[] 
    {"applicationContext.xml"}); 
    IBanqueMetier metier=(IBanqueMetier) context.getBean("metier"); 
    metier.addClient(new Client("C1", "AD1")); 
    metier.addClient(new Client("C2", "AD2")); 
} 

和這個1RST錯誤:

Exception in thread "main"org.springframework.beans.factory.BeanCreationException: 
     Error creating bean with name 'dao': Injection of persistence dependencies 

failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: org.gestion.bp.entities.Compte.employe 
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:342) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) 
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) 
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) 
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) 
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) 
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) 
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) 
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93) 
+0

你的意思是錯誤消息「非法嘗試映射的定義作出了錯誤作爲OneToMany,ManyToMany或CollectionOfElements的非集合:org.gestion.bp.entities.Compte.employe「?而且? –

回答

1

對於Spring異常,重要的是要讀取整個消息直到最後。我通常會採取折中的消息成幾行,以使其更易於閱讀:

Exception in thread "main"org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'dao': Injection of persistence dependencies failed; 
nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: 
Invocation of init method failed; 
nested exception is org.hibernate.AnnotationException: 
Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: 
org.gestion.bp.entities.Compte.employe 

正如你所看到的,你在場上org.gestion.bp.entities.Compte.employe

+0

感謝它現在修復,我真的很喜歡 – Ali