[英]Spring mvc + hibernate Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean
Good morning all. 大家早上好。 I'm dealing with it for 3 days without getting a solution, I tried to read other similar questione, but no one helped me. 我已经处理了3天,但没有找到解决方案,我尝试阅读其他类似的问题,但没有人帮助过我。 I have my first Spring mvc hibernate application. 我有我的第一个Spring mvc hibernate应用程序。 When deploying it i got this stack trace. 部署它时,我得到了此堆栈跟踪。 I'm deploying it on Tomcat 8 我正在Tomcat 8上部署它
ERROR [localhost-startStop-3]: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'illuminazioneService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: public it.besmart.dao.IlluminazioneDao it.besmart.service.IlluminazioneServiceImpl.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'illuminazioneDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory it.besmart.dao.AbstractDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionfactory' defined in class path resource [it/besmart/config/HibernateConfiguration.class]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1768)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: public it.besmart.dao.IlluminazioneDao it.besmart.service.IlluminazioneServiceImpl.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'illuminazioneDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory it.besmart.dao.AbstractDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionfactory' defined in class path resource [it/besmart/config/HibernateConfiguration.class]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 26 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'illuminazioneDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory it.besmart.dao.AbstractDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionfactory' defined in class path resource [it/besmart/config/HibernateConfiguration.class]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
... 28 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory it.besmart.dao.AbstractDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionfactory' defined in class path resource [it/besmart/config/HibernateConfiguration.class]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 39 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionfactory' defined in class path resource [it/besmart/config/HibernateConfiguration.class]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
... 41 more
Caused by: java.lang.AbstractMethodError
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:278)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:372)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:454)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:439)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
... 51 more
As I can understand there is a problem with bean creation, maybe in HibernateConfiguration. 据我了解,可能是HibernateConfiguration中的bean创建存在问题。
This is HibernateConfiguration.class 这是HibernateConfiguration.class
package it.besmart.config;
import java.util.Properties;
import javax.sql.DataSource;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.hibernate4.HibernateTransactionManager;
import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableTransactionManagement
@ComponentScan({ "it.besmart.config" })
@PropertySource(value = { "classpath:db.properties" })
public class HibernateConfiguration {
@Autowired
private Environment environment;
@Bean
public LocalSessionFactoryBean sessionfactory(){
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
sessionFactory.setDataSource(dataSource());
sessionFactory.setPackagesToScan(new String[] {"it.besmart.models"});
sessionFactory.setHibernateProperties(hibernateProperties());
return sessionFactory;
}
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(environment.getRequiredProperty("jdbc.driverClassName"));
dataSource.setUrl(environment.getRequiredProperty("jdbc.url"));
dataSource.setUsername(environment.getRequiredProperty("jdbc.username"));
dataSource.setPassword(environment.getRequiredProperty("jdbc.password"));
return dataSource;
}
private Properties hibernateProperties() {
Properties properties = new Properties();
properties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect"));
properties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql"));
properties.put("hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql"));
return properties;
}
@Bean
@Autowired
public HibernateTransactionManager transactionManager(SessionFactory s) {
HibernateTransactionManager txManager = new HibernateTransactionManager();
txManager.setSessionFactory(s);
return txManager;
}
}
db.properties is in the class path (main/src/resources) and the class is in it.besmart.configuration package and the models in it.besmart.models db.properties位于类路径(main / src / resources)中,并且该类位于it.besmart.configuration程序包和其中的模型中。besmart.models
Than I have IlluminazioneService 比我有IlluminazioneService
package it.besmart.service;
import it.besmart.models.Illuminazione;
import java.util.List;
public interface IlluminazioneService {
List <Illuminazione> showIlluminazione();
Illuminazione findByIdPostoLuce(int idPostoLuce);
Illuminazione findByIsLit(int isLit);
void saveIlluminazione(Illuminazione illuminazione);
void deleteOccupazioneByIdPostoLuce(int idPostoLuce);
}
IlluminazioneDao IlluminazioneDao
package it.besmart.dao;
import it.besmart.models.Illuminazione;
import java.util.Date;
import java.util.List;
public interface IlluminazioneDao {
List <Illuminazione> showIlluminazione();
Illuminazione findByIdPostoLuce(int idPostoLuce);
Illuminazione findByIsLit(int isLit);
void saveIlluminazione(Illuminazione illuminazione);
void deleteOccupazioneByIdPostoLuce(int idPostoLuce);
}
Illuminazione ILLUMINAZIONE
package it.besmart.models;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
/**
* Illuminazione generated by hbm2java
*/
@Entity
@Table(name = "illuminazione", catalog = "SMARTPARK")
public class Illuminazione implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private Integer idEvento;
private int idPostoLuce;
private Date dateTime;
private boolean isLit;
public Illuminazione() {
}
public Illuminazione(int idPostoLuce, Date dateTime, boolean isLit) {
this.idPostoLuce = idPostoLuce;
this.dateTime = dateTime;
this.isLit = isLit;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id_evento", unique = true, nullable = false)
public Integer getIdEvento() {
return this.idEvento;
}
public void setIdEvento(Integer idEvento) {
this.idEvento = idEvento;
}
@NotNull
@Column(name = "id_posto_luce", nullable = false)
public int getIdPostoLuce() {
return this.idPostoLuce;
}
public void setIdPostoLuce(int idPostoLuce) {
this.idPostoLuce = idPostoLuce;
}
@NotNull
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "date_time", nullable = false, length = 19)
public Date getDateTime() {
return this.dateTime;
}
public void setDateTime(Date dateTime) {
this.dateTime = dateTime;
}
@NotNull
@Column(name = "isLit", nullable = false)
public boolean isIsLit() {
return this.isLit;
}
public void setIsLit(boolean isLit) {
this.isLit = isLit;
}
}
AbstractDao is 摘要道是
package it.besmart.dao;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
public abstract class AbstractDao<PK extends Serializable, T> {
private final Class<T> persistentClass;
@SuppressWarnings("unchecked")
public AbstractDao(){
this.persistentClass =(Class<T>) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[1];
}
@Autowired
private SessionFactory sessionFactory;
protected Session getSession(){
return sessionFactory.getCurrentSession();
}
@SuppressWarnings("unchecked")
public T getByKey(PK key) {
return (T) getSession().get(persistentClass, key);
}
public void persist(T entity) {
getSession().persist(entity);
}
public void delete(T entity) {
getSession().delete(entity);
}
protected Criteria createEntityCriteria(){
return getSession().createCriteria(persistentClass);
}
}
I don't know if anything else could be useful for a solution. 我不知道其他任何解决方案是否有用。 I have also the implementation classes, if needed. 如果需要,我也有实现类。 Thanks to all 谢谢大家
EDIT 编辑
This is my pom.xml 这是我的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>it.besmart</groupId>
<artifactId>webapp</artifactId>
<version>0.0.1</version>
<packaging>war</packaging>
<name>webapp</name>
<url>http://www.beingsmart.it</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springframework.version>4.2.3.RELEASE</springframework.version>
<hibernate.version>5.0.3.Final</hibernate.version>
<mysql.connector.version>5.1.37</mysql.connector.version>
</properties>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.13</version>
</dependency>
<dependency>
<groupId>com.pi4j</groupId>
<artifactId>pi4j-core</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${springframework.version}</version>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<!-- jsr303 validation -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.1.3.Final</version>
</dependency>
<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector.version}</version>
</dependency>
<!-- Servlet+JSP+JSTL -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<organization>
<name>Be Smart</name>
<url>http://www.beingsmart.it</url>
</organization>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<warName>webapp</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<finalName>webapp</finalName>
</build>
</project>
And last, the IlluminzioneDaoImpl class 最后是IlluminzioneDaoImpl类
package it.besmart.dao;
import it.besmart.models.Illuminazione;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;
@Repository("illuminazioneDao")
public class IlluminazioneDaoImpl extends AbstractDao<Integer, Illuminazione> implements IlluminazioneDao{
@SuppressWarnings("unchecked")
public List<Illuminazione> showIlluminazione() {
// TODO Auto-generated method stub
Criteria criteria = createEntityCriteria();
return (List <Illuminazione>) criteria.list();
}
public Illuminazione findByIdPostoLuce(int idPostoLuce) {
// TODO Auto-generated method stub
return getByKey(idPostoLuce);
}
public Illuminazione findByIsLit(int isLit) {
// TODO Auto-generated method stub
return getByKey(isLit);
}
public void saveIlluminazione(Illuminazione illuminazione) {
// TODO Auto-generated method stub
persist(illuminazione);
}
public void deleteOccupazioneByIdPostoLuce(int idPostoLuce) {
// TODO Auto-generated method stub
Query query = getSession().createSQLQuery("delete from illuminazione where idPostoLuce = :idPostoLuce");
query.setParameter("idPostoLuce", idPostoLuce);
query.executeUpdate();
}
}
LocalSessionFactoryBean is a spring-class, dedicated to work with hibernate 4. The AbstractMethodError leads to the conclusion that the method/constructor the spring-class is trying to call does not exist on the hibernate-class you have on the classpath. LocalSessionFactoryBean的是弹簧类,专用与Hibernate 4. AbstractMethodError导致该方法/构造弹簧类试图调用您所拥有的类路径的休眠级不存在的结论工作。 Could it be that you have different versions of hibernate-jars in your classpath? 可能是您的类路径中有不同版本的hibernate-jars吗?
i would step into the source code of the classes involved. 我将介入相关类的源代码。 i guess you will find a method-call in SessionFactoryImpl to a method/constructor that does not exist for the class-version you have on the classpath. 我猜您会在SessionFactoryImpl中找到对您在类路径上的类版本不存在的方法/构造函数的方法调用。 it could be an unsupported ehcache-version or envers-version perhaps. 可能是不受支持的ehcache版本或envers版本。
it seems the error has something todo with an incompatible integrator, does that ring a bell? 似乎错误与不兼容的积分器有关,这是否会引起意外?
http://grepcode.com/file/repo1.maven.org/maven2/org.hibernate/hibernate-core/5.0.0.CR3/org/hibernate/internal/SessionFactoryImpl.java#SessionFactoryImpl http://grepcode.com/file/repo1.maven.org/maven2/org.hibernate/hibernate-core/5.0.0.CR3/org/hibernate/internal/SessionFactoryImpl.java#SessionFactoryImpl
Spring tries to set the sessionFactory
on the abstract class AbstractDao
, and this can not work as the error message notices. Spring尝试在抽象类AbstractDao
上设置sessionFactory
,这不能正常工作,因为错误消息会通知您。
Do you have an @Component
annotation on the concrete DAO? 在具体的DAO上是否有@Component
批注?
I had a similar problem with failed Context initialization . 失败的上下文初始化也有类似的问题。 I am currently with Spring 5.1.0.Final . 我目前在Spring 5.1.0.Final中 。 It is logical to use and the latest version of hibernate-validator, but it turned out that the error appears when you put newer than hibernate-validator 4.3.2.Final . 逻辑上使用最新版本的hibernate-validator是合乎逻辑的,但事实证明,当您输入的内容比hibernate-validator 4.3.2.Final更新时,就会出现该错误。 I can not explain it, but it helped me. 我无法解释,但是它帮助了我。 Maybe you should try with lower hibernate-validator version . 也许您应该尝试使用较低的hibernate-validator版本 。
I hope I've been helpful. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.