Spring整合Hibernate报错:annotatedClasses is not writable or has an invalid setter method
Spring 整合Hibernate时报错:
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'sessionFactory' defined in class path resource [spring/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'annotatedClasses' of bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]:
Bean property 'annotatedClasses' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
......
原因在于选择Hibernate的sessionFactory时有两种:
1. LocalSessionFactoryBean,使用*.hbm.xml进行配置。而且bean的class是hibernate3.LocalSessionFactoryBean:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="mappingResources">
<list>
<value>User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop>
</props>
</property>
</bean>
2. AnnotationSessionFactoryBean。bean的class是AnnotationSessionFactoryBean
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses</span>">
<list>
<value>com.xxx.model.User</span></value>
</list>
</property>
<property name="hibernateProperties">
<!-- <value>
hibernate.dialect=org.hibernate.dialect.HSQLDialect
</value> -->
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
在获取session的时候,使用Session s = sessionFactory.openSession();
Spring整合Hibernate报错:annotatedClasses is not writable or has an invalid setter method的更多相关文章
- spring整合quartz报错
今天spring整合quartz报错,最后一步步排查,发现是和redis依赖冲突,最后redis升级了一下,问题解决. 总结:发现问题,逐一排查,如果是整合问题,报类加载不到的错误,大概率是和其他组件 ...
- spring整合junit报错
1.Could not autowire field: private javax.servlet.http.HttpServletRequest 参考:https://www.cnblogs.com ...
- spring整合hibernate时报错:org.hibernte.engine.transaction.spi.transactioncontext
错误提示:Caused by:java.lang.ClassNotFoundException: org.hibernte.engine.transaction.spi.transactioncont ...
- spring+hibernate整合:报错org.hibernate.HibernateException: No Session found for current thread
spring+hibernate整合:报错信息如下 org.hibernate.HibernateException: No Session found for current thread at o ...
- 【Java EE 学习 53】【Spring学习第五天】【Spring整合Hibernate】【Spring整合Hibernate、Struts2】【问题:整合hibernate之后事务不能回滚】
一.Spring整合Hibernate 1.如果一个DAO 类继承了HibernateDaoSupport,只需要在spring配置文件中注入SessionFactory就可以了:如果一个DAO类没有 ...
- spring整合hibernate
spring整合hibernate包括三部分:hibernate的配置.hibernate核心对象交给spring管理.事务由AOP控制 好处: 由java代码进行配置,摆脱硬编码,连接数据库等信息更 ...
- Spring整合Hibernate笔记
1. Spring 指定datasource a) 参考文档,找dbcp.BasicDataSource i. c3p0 ii. dbcp <bean id="dataSource&q ...
- Spring整合Redis时报错:java.util.NoSuchElementException: Unable to validate object
我在Spring整合Redis时报错,我是犯了一个很低级的错误! 我设置了Redis的访问密码,在Spring的配置文件却没有配置密码这一项,配置上密码后,终于不报错了!
- Spring整合Hibernate的XML文件配置,以及web.xml文件配置
利用Spring整合Hibernate时的XML文件配置 applicationContext.xml <?xml version="1.0" encoding=" ...
随机推荐
- leetcode.分治.241为运算表达式设计优先级-Java
1. 具体题目 给定一个含有数字和运算符的字符串,为表达式添加括号,改变其运算优先级以求出不同的结果.你需要给出所有可能的组合的结果.有效的运算符号包含 +, - 以及 * . 示例 1: 输入: & ...
- 恐怖的奴隶主(bob)
题目描述 小L热衷于undercards. 在undercards中,有四个格子.每个格子要么是空的,要么住着一只BigBob. 每个BigBob有一个不超过k的血量:血量减到0视为死亡.那个格子随即 ...
- Python:我可以使用类变量作为线程锁吗?
我正在考虑使用类变量作为线程锁,因为我不想在全局变量中定义锁并且还想防止死锁.这实际上有用吗?例: import threading class A(object): lock = threading ...
- JavaScript阶乘算法
题目: 计算所提供整数的阶乘. 如果使用字母n代表一个整数,则阶乘是所有小于或等于n的整数的乘积. 阶乘通常简写成 n! 例如: 5! = 1 * 2 * 3 * 4 * 5 = 120 使用递归实现 ...
- webpack从入门到精通(一)
1.webpack的使用背景: 目前国内前端开发都是基于模块化的 2.webpack的作用有哪些: 3.webpack四大核心理念: entry,output,loaders,plugins 4.使用 ...
- 【知识强化】第五章 传输层 5.3 TCP协议
这节课我们来学习一下TCP协议的特点以及TCP报文段的格式. 首先呢我们来看一下TCP有哪些特点呢.之前我们说过TCP它是一个比较可靠的面向连接的协议,所以最主要的特点它是可以面向连接的一种传输层协议 ...
- setbuf, setbuffer, setlinebuf, setvbuf - 流缓冲操作
SYNOPSIS 总览 #include <stdio.h> void setbuf(FILE *stream, char *buf); void setbuffer(FILE *stre ...
- ARM指令adr adrl ldr mov
ADR是一条小范围的地址读取伪指令,它将基于PC的相对偏移的地址值读到目标寄存器中.格式:ADR register,exper. 编译源程序时,汇编器首先计算当前PC值(当前指令位置)到exper的距 ...
- EventBus总结(原)
1.EventBus的作用 EventBus is a publish/subscribe event bus for Android and Java. EventBus可以被用来在各种自定义的监听 ...
- tarjan强连通缩点
int dfn[maxn],low[maxn],belong[maxn]; bool instk[maxn]; stack<int>stk; void tarjan(int u){ dfn ...