java – Spring JPA / Hibernate:导入bean定义失败
发布时间:2020-12-14 05:29:07 所属栏目:Java 来源:网络整理
导读:把我的头撞在墙上几个小时,无法解决这个问题,似乎是我的配置设置中的一个错误,也可能是依赖冲突或缺少依赖.有什么想法吗? 相关依赖: Spring Data Commons Core 1.2.0Spring Data JPA 1.8.0Hibernate Core 5.0Hibernate JPA 2.1 Eclipse中的错误消息: Conf
把我的头撞在墙上几个小时,无法解决这个问题,似乎是我的配置设置中的一个错误,也可能是依赖冲突或缺少依赖.有什么想法吗?
相关依赖: Spring Data Commons Core 1.2.0 Spring Data JPA 1.8.0 Hibernate Core 5.0 Hibernate JPA 2.1 Eclipse中的错误消息: Configuration problem: Failed to import bean definitions from relative location [SpringDbContext.xml] Offending resource: class path resource [SpringAppContext.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 43 in XML document from class path resource [SpringDbContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; systemId: http://www.springframework.org/schema/data/jpa/spring-jpa-1.8.xsd; lineNumber: 43; columnNumber: 63; src-resolve: Cannot resolve the name 'repository:auditing-attributes' to a(n) 'attribute group' component.at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70) SpringAppContext.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <import resource="SpringWebContext.xml"/> <import resource="SpringDbContext.xml"/> <import resource="SpringSecurityContext.xml"/> <import resource="SpringSocialContext.xml"/> <context:component-scan base-package="com.metagravy.ark.security"/> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename" value="i18n/messages"/> <property name="useCodeAsDefaultMessage" value="true"/> </bean> </beans> Hibernate配置: hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect hibernate.format_sql=true hibernate.hbm2ddl.auto=create-drop hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy hibernate.show_sql=false SpringDbContext.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.8.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> <context:property-placeholder location="classpath:application.properties"/> <bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource"> <property name="driverClass" value="${db.driver}"/> <property name="jdbcUrl" value="${db.url}"/> <property name="username" value="${db.username}"/> <property name="password" value="${db.password}"/> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> <tx:annotation-driven/> <bean id="hibernateJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter"/> <property name="packagesToScan" value="com.metagravy.ark"/> <property name="jpaProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.ejb.naming_strategy">${hibernate.ejb.naming_strategy}</prop> <prop key="hibernate.format_sql">${hibernate.format_sql}</prop> <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> </props> </property> </bean> <jpa:repositories base-package="com.metagravy.ark.security"/> </beans> 解决方法
感谢您的帮助,我将spring-data-commons从1.2升级到1.10,并解决了错误.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 如何在java中将String转换为Date,无论系统格式是什么[复制]
- java – 你能用Future.cancel(true)中断BufferedReader.rea
- JSP Exception.initCause()方法:设置初始化的异常信息
- JavaFX:绘制锐利的细线
- java – 内存如何分配给lambda |它是如何通过非超类引用变量
- Java读取Excel指定列的数据详细教程和注意事项
- java – 如果不存在,将一个新值添加到地图中,或者添加它
- Java 1.8 新特性
- java – Google Cloud Platform:无法从Container Engine
- java-ee – 比较OpenEjb和Glassfish