无法创建内部 bean 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter....'
Cannot create inner bean 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter....'
我正在尝试 运行 我的 JBoss 服务器,但我得到一个 org.springframework.beans.factory.BeanCreationException。我没有使用 persistence.xml 来设置休眠配置。控制台错误是:
14:08:26,818 错误 [org.jboss.msc.service.fail](MSC 服务线程 1-2)MSC000001:无法启动服务 jboss.undertow.deployment.default-server.default-host./CadastroAssembleia:org.jboss.msc.service.StartException 在服务 jboss.undertow.deployment.default-server.default-host./CadastroAssembleia: 启动服务失败
在 org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
在 java.util.concurrent.ThreadPoolExecutor.runWorker(来源不明)[rt.jar:1.8.0_25]
在 java.util.concurrent.ThreadPoolExecutor$Worker.run(来源不明)[rt.jar:1.8.0_25]
在 java.lang.Thread.run(来源不明)[rt.jar:1.8.0_25]
由以下原因引起:java.lang.RuntimeException:org.springframework.beans.factory.BeanCreationException:创建名称为 'entityManagerFactory' 的 bean 在 ServletContext 资源 [/WEB-INF/applicationContext.xml] 中定义时出错:无法创建内部 bean 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#629919a4' 类型 [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter] 同时设置 bean 属性 'jpaVendorAdapter';嵌套异常是 org.springframework.beans.factory.BeanCreationException:在 ServletContext 资源 [/WEB-INF/applicationContext.xml] 中定义名称 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#629919a4' 创建 bean 时出错:bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]:构造函数抛出异常;嵌套异常是 java.lang.IllegalStateException:无法确定 Hibernate PersistenceProvider
在 io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:222)
在 org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)
在 org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
在 org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
在 org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
... 3 更多
由以下原因引起:org.springframework.beans.factory.BeanCreationException:在 ServletContext 资源 [/WEB-INF/applicationContext.xml] 中创建名称为 'entityManagerFactory' 的 bean 时出错:无法创建类型为 [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter] 同时设置 bean 属性 'jpaVendorAdapter';嵌套异常是 org.springframework.beans.factory.BeanCreationException:在 ServletContext 资源 [/WEB-INF/applicationContext.xml] 中定义名称 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#629919a4' 创建 bean 时出错:bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]:构造函数抛出异常;嵌套异常是 java.lang.IllegalStateException:无法确定 Hibernate PersistenceProvider
在 org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:313)
在 org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1469)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
在 org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
在 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
在 org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956)
在 org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747)
在 org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
在 org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
在 org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
在 org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
在 io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173)
在 io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:193)
... 还有 7 个
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#629919a4' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]:构造函数抛出异常;嵌套异常是 java.lang.IllegalStateException:无法确定 Hibernate PersistenceProvider
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1093)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean 实例 (AbstractAutowireCapableBeanFactory.java:1038)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
在 org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:299)
... 还有 24 个
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]: 构造函数抛出异常;嵌套异常是 java.lang.IllegalStateException:无法确定 Hibernate PersistenceProvider
在 org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
在 org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1086)
... 还有 28 个
原因:java.lang.IllegalStateException:无法确定 Hibernate PersistenceProvider
在 org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.(HibernateJpaVendorAdapter.java:96)
在 sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)[rt.jar:1.8.0_25]
在 sun.reflect.NativeConstructorAccessorImpl.newInstance(未知来源)[rt.jar:1.8.0_25]
在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(来源不明)[rt.jar:1.8.0_25]
在 java.lang.reflect.Constructor.newInstance(来源不明)[rt.jar:1.8.0_25]
在 org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
... 30 更多
由以下原因引起:java.lang.ClassNotFoundException:org.hibernate.ejb.HibernateEntityManagerFactory 来自 [Module "deployment.CadastroAssembleia.war:main" from Service Module Loader]
在 org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
在 org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
在 org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
在 org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
在 org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
在 org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.(HibernateJpaVendorAdapter.java:89)
... 还有 35 个
我的applicationContext.xml是:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:repository="http://www.springframework.org/schema/data/repository"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/repository
http://www.springframework.org/schema/data/repository/spring-repository-1.5.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<!-- Informa o pacote onde o Spring ira buscar as classes anotadas -->
<context:component-scan base-package="br.com.cadastroassembleia" />
<!-- Informa o Spring Data o paconte onde estão os repositórios -->
<jpa:repositories base-package="br.com.cadastroassembleia.dao" />
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
<property name="generateDdl" value="true" />
<property name="showSql" value="true" />
</bean>
</property>
<property name="packagesToScan" value="br.com.cadastroassembleia.entity" />
<property name="dataSource" ref="dataSource" />
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
</bean>
<!-- Data source -->
<bean id="DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl"
value="jdbc:mysql://localhost:3306/cadastro_assembleia" />
<property name="user" value="root" />
<property name="password" value="root" />
<property name="maxPoolSize" value="10" />
<property name="maxStatements" value="0" />
<property name="minPoolSize" value="5" />
</bean>
<!-- Habilita a configuração de transações baseadas em anotations -->
<tx:annotation-driven transaction-manager="txManager" />
<!-- Transaction Manager -->
<bean id="txManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
提前致谢!!
您似乎错过了 hibernate-entitymanager.jar.
下载它并将其添加到您的类路径中。
以下留言点是:
Caused by: java.lang.ClassNotFoundException: org.hibernate.ejb.HibernateEntityManagerFactory
如果您使用 maven,请将以下依赖项添加到您的 pom:
我猜你用的是maven?所以将其添加到您的 pom:
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version><required_version></version>
</dependency>
我正在尝试 运行 我的 JBoss 服务器,但我得到一个 org.springframework.beans.factory.BeanCreationException。我没有使用 persistence.xml 来设置休眠配置。控制台错误是:
14:08:26,818 错误 [org.jboss.msc.service.fail](MSC 服务线程 1-2)MSC000001:无法启动服务 jboss.undertow.deployment.default-server.default-host./CadastroAssembleia:org.jboss.msc.service.StartException 在服务 jboss.undertow.deployment.default-server.default-host./CadastroAssembleia: 启动服务失败
在 org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
在 java.util.concurrent.ThreadPoolExecutor.runWorker(来源不明)[rt.jar:1.8.0_25]
在 java.util.concurrent.ThreadPoolExecutor$Worker.run(来源不明)[rt.jar:1.8.0_25]
在 java.lang.Thread.run(来源不明)[rt.jar:1.8.0_25]
由以下原因引起:java.lang.RuntimeException:org.springframework.beans.factory.BeanCreationException:创建名称为 'entityManagerFactory' 的 bean 在 ServletContext 资源 [/WEB-INF/applicationContext.xml] 中定义时出错:无法创建内部 bean 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#629919a4' 类型 [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter] 同时设置 bean 属性 'jpaVendorAdapter';嵌套异常是 org.springframework.beans.factory.BeanCreationException:在 ServletContext 资源 [/WEB-INF/applicationContext.xml] 中定义名称 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#629919a4' 创建 bean 时出错:bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]:构造函数抛出异常;嵌套异常是 java.lang.IllegalStateException:无法确定 Hibernate PersistenceProvider
在 io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:222)
在 org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)
在 org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
在 org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
在 org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
... 3 更多
由以下原因引起:org.springframework.beans.factory.BeanCreationException:在 ServletContext 资源 [/WEB-INF/applicationContext.xml] 中创建名称为 'entityManagerFactory' 的 bean 时出错:无法创建类型为 [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter] 同时设置 bean 属性 'jpaVendorAdapter';嵌套异常是 org.springframework.beans.factory.BeanCreationException:在 ServletContext 资源 [/WEB-INF/applicationContext.xml] 中定义名称 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#629919a4' 创建 bean 时出错:bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]:构造函数抛出异常;嵌套异常是 java.lang.IllegalStateException:无法确定 Hibernate PersistenceProvider
在 org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:313)
在 org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1469)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
在 org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
在 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
在 org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956)
在 org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747)
在 org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
在 org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
在 org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
在 org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
在 io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173)
在 io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:193)
... 还有 7 个
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#629919a4' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]:构造函数抛出异常;嵌套异常是 java.lang.IllegalStateException:无法确定 Hibernate PersistenceProvider
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1093)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean 实例 (AbstractAutowireCapableBeanFactory.java:1038)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
在 org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:299)
... 还有 24 个
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]: 构造函数抛出异常;嵌套异常是 java.lang.IllegalStateException:无法确定 Hibernate PersistenceProvider
在 org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
在 org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1086)
... 还有 28 个
原因:java.lang.IllegalStateException:无法确定 Hibernate PersistenceProvider
在 org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.(HibernateJpaVendorAdapter.java:96)
在 sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)[rt.jar:1.8.0_25]
在 sun.reflect.NativeConstructorAccessorImpl.newInstance(未知来源)[rt.jar:1.8.0_25]
在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(来源不明)[rt.jar:1.8.0_25]
在 java.lang.reflect.Constructor.newInstance(来源不明)[rt.jar:1.8.0_25]
在 org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
... 30 更多
由以下原因引起:java.lang.ClassNotFoundException:org.hibernate.ejb.HibernateEntityManagerFactory 来自 [Module "deployment.CadastroAssembleia.war:main" from Service Module Loader]
在 org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
在 org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
在 org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
在 org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
在 org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
在 org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.(HibernateJpaVendorAdapter.java:89)
... 还有 35 个
我的applicationContext.xml是:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:repository="http://www.springframework.org/schema/data/repository"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/repository
http://www.springframework.org/schema/data/repository/spring-repository-1.5.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<!-- Informa o pacote onde o Spring ira buscar as classes anotadas -->
<context:component-scan base-package="br.com.cadastroassembleia" />
<!-- Informa o Spring Data o paconte onde estão os repositórios -->
<jpa:repositories base-package="br.com.cadastroassembleia.dao" />
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
<property name="generateDdl" value="true" />
<property name="showSql" value="true" />
</bean>
</property>
<property name="packagesToScan" value="br.com.cadastroassembleia.entity" />
<property name="dataSource" ref="dataSource" />
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
</bean>
<!-- Data source -->
<bean id="DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl"
value="jdbc:mysql://localhost:3306/cadastro_assembleia" />
<property name="user" value="root" />
<property name="password" value="root" />
<property name="maxPoolSize" value="10" />
<property name="maxStatements" value="0" />
<property name="minPoolSize" value="5" />
</bean>
<!-- Habilita a configuração de transações baseadas em anotations -->
<tx:annotation-driven transaction-manager="txManager" />
<!-- Transaction Manager -->
<bean id="txManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
提前致谢!!
您似乎错过了 hibernate-entitymanager.jar.
下载它并将其添加到您的类路径中。
以下留言点是:
Caused by: java.lang.ClassNotFoundException: org.hibernate.ejb.HibernateEntityManagerFactory
如果您使用 maven,请将以下依赖项添加到您的 pom:
我猜你用的是maven?所以将其添加到您的 pom:
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version><required_version></version>
</dependency>