I'm creating application with Spring Data JPA. I get above error when I execute the main methode:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'poleRepository': FactoryBean threw exception on object creation; nested exception is java.lang.NoSuchMethodError: org.springframework.data.repository.core.RepositoryMetadata.getDomainType()Ljava/lang/Class;
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanIn stance(AbstractBeanFactory.java:1414)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at model.Main.main(Main.java:13)
Caused by: java.lang.NoSuchMethodError: org.springframework.data.repository.core.RepositoryMetadata.getDomainType()Ljava /lang/Class;
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRe pository(JpaRepositoryFactory.java:87)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:70)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:146)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:120)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:39)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 10 more
this is the code:
package model;
import beans.*;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("META-INF/beans.xml");
// Get RegistrationBean That Defined
RegistrationBean registrationBean = (RegistrationBean)context.getBean("registrationBean");
JourOff j = new JourOff();
j.setAnnee(2014);
j.setNomJour("vendredi");
registrationBean.getPoleReposigtory().save(j);
}
}
this is my configuration beans.xml
<context:annotation-config />
<!--Enable the component scan (auto wiring etc) for the following package-->
<context:annotation-config base-package="beans" />
<jpa:repositories base-package="respo" />
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcesso r" />
<bean class="org.springframework.orm.jpa.JpaTransactionManager"
id="transactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<!--This defines the entity manager factory with some custom properties-->
<bean id='entityManagerFactory'
class='org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean'>
<property name="persistenceUnitName" value="SpringDataTest2"/>
<property name='dataSource' ref='dataSource' />
<property name="jpaPropertyMap">
<map>
<entry key="eclipselink.weaving" value="false"/>
</map>
</property>
</bean>
<!-- This defines the hsqldb data source -->
<bean id='dataSource'
class='org.springframework.jdbc.datasource.DriverManagerDataSource'>
<property name='driverClassName' value='org.postgresql.Driver' />
<property name='url' value='jdbc:postgresql://localhost:5432/postgres' />
<property name='username' value='postgres' />
<property name='password' value='' />
</bean>
</beans>
this is my respository:
package respo;
import model.JourOff;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface PoleRepository extends CrudRepository<JourOff, Integer> {
@Override
public JourOff findOne(Integer id);
}
and this is the registration bean:
package beans;
import respo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class RegistrationBean {
@Autowired
private PoleRepository poleReposigtory;
public RegistrationBean(){
}
public PoleRepository getPoleReposigtory() {
return poleReposigtory;
}
public void setPoleReposigtory(PoleRepository poleReposigtory) {
this.poleReposigtory = poleReposigtory;
}
}
need your help
Aucun commentaire:
Enregistrer un commentaire