spring+hibernate hbm2ddl.auto 的问题
spring+hibernate这是我的配置文件<beanid="dataSourceByControlCenter"class="org.logicalcobwebs....
spring+hibernate这是我的配置文件 <bean id="dataSourceByControlCenter" class="org.logicalcobwebs.proxool.ProxoolDataSource" destroy-method="close">
<property name="driver" value="${center.db.driver}"/>
<property name="driverUrl" value="${center.db.url}"/>
.............................
<property name="hbm2ddl.auto" value="update"/>
</bean>
我一加上这句 <property name="hbm2ddl.auto" value="update"/>程序就会出异常
Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'hbm2ddl' of bean class [org.logicalcobwebs.proxool.ProxoolDataSource]: Bean property 'hbm2ddl' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? 展开
<property name="driver" value="${center.db.driver}"/>
<property name="driverUrl" value="${center.db.url}"/>
.............................
<property name="hbm2ddl.auto" value="update"/>
</bean>
我一加上这句 <property name="hbm2ddl.auto" value="update"/>程序就会出异常
Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'hbm2ddl' of bean class [org.logicalcobwebs.proxool.ProxoolDataSource]: Bean property 'hbm2ddl' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? 展开
2个回答
展开全部
这个不是配在datasource里的,而是配在sessionfactory里
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!-- 加载驱动 -->
<property name="driverClass" value="${jdbc.driverClassName}" />
<!-- database url -->
<property name="jdbcUrl" value="${jdbc.url}" />
<!-- database username -->
<property name="user" value="${jdbc.username}" />
<!-- database password -->
<property name="password" value="${jdbc.password}" />
<!-- 连接关闭时默认将所有未提交的操作回滚。默认为false -->
<property name="autoCommitOnClose" value="${jdbc.autoCommitOnClose}" />
<!-- 连接池中保留的最小连接数 -->
<property name="minPoolSize" value="${jdbc.minPoolSize}" />
<!-- 连接池中保留的最大连接数。默认为15 -->
<property name="maxPoolSize" value="${jdbc.maxPoolSize}" />
<!-- 初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。默认为3 -->
<property name="initialPoolSize" value="${jdbc.initialPoolSize}" />
<!-- 最大空闲时间,超过空闲时间的连接将被丢弃。为0或负数则永不丢弃。默认为0秒 -->
<property name="maxIdleTime" value="${jdbc.maxIdleTime}" />
<!-- 当连接池中的连接用完时,C3P0一次性创建新连接的数目。默认为3 -->
<property name="acquireIncrement" value="${jdbc.acquireIncrement}" />
<!-- 定义在从数据库获取新连接失败后重复尝试获取的次数,默认为30 -->
<property name="acquireRetryAttempts" value="${jdbc.acquireRetryAttempts}" />
<!-- 当连接池用完时客户端调用getConnection()后等待获取新连接的时间,超时后将抛出SQLException,如设为0则无限期等待。单位毫秒,默认为0 -->
<property name="checkoutTimeout" value="${jdbc.checkoutTimeout}" />
</bean>
<!-- 创建sessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="namingStrategy">
<bean class="org.hibernate.cfg.ImprovedNamingStrategy" />
</property>
<property name="hibernateProperties">
<props>
<!-- 数据库方言 -->
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<!-- 是否在控制台输出sql语句 -->
<prop key="hibernate.show_sql">${hibernate.showSQL}</prop>
<!-- 是否在控制台格式化sql语句 -->
<prop key="hibernate.format_sql">${hibernate.formatSQL}</prop>
<!-- 自动创建修改表 -->
<!-- <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl}</prop> -->
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">classpath:ehcache-hibernate-local.xml</prop>
<prop key="hibernate.c3p0.max_statements">50</prop>
</props>
</property>
<property name="packagesToScan">
<value></value>
</property>
</bean>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!-- 加载驱动 -->
<property name="driverClass" value="${jdbc.driverClassName}" />
<!-- database url -->
<property name="jdbcUrl" value="${jdbc.url}" />
<!-- database username -->
<property name="user" value="${jdbc.username}" />
<!-- database password -->
<property name="password" value="${jdbc.password}" />
<!-- 连接关闭时默认将所有未提交的操作回滚。默认为false -->
<property name="autoCommitOnClose" value="${jdbc.autoCommitOnClose}" />
<!-- 连接池中保留的最小连接数 -->
<property name="minPoolSize" value="${jdbc.minPoolSize}" />
<!-- 连接池中保留的最大连接数。默认为15 -->
<property name="maxPoolSize" value="${jdbc.maxPoolSize}" />
<!-- 初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。默认为3 -->
<property name="initialPoolSize" value="${jdbc.initialPoolSize}" />
<!-- 最大空闲时间,超过空闲时间的连接将被丢弃。为0或负数则永不丢弃。默认为0秒 -->
<property name="maxIdleTime" value="${jdbc.maxIdleTime}" />
<!-- 当连接池中的连接用完时,C3P0一次性创建新连接的数目。默认为3 -->
<property name="acquireIncrement" value="${jdbc.acquireIncrement}" />
<!-- 定义在从数据库获取新连接失败后重复尝试获取的次数,默认为30 -->
<property name="acquireRetryAttempts" value="${jdbc.acquireRetryAttempts}" />
<!-- 当连接池用完时客户端调用getConnection()后等待获取新连接的时间,超时后将抛出SQLException,如设为0则无限期等待。单位毫秒,默认为0 -->
<property name="checkoutTimeout" value="${jdbc.checkoutTimeout}" />
</bean>
<!-- 创建sessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="namingStrategy">
<bean class="org.hibernate.cfg.ImprovedNamingStrategy" />
</property>
<property name="hibernateProperties">
<props>
<!-- 数据库方言 -->
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<!-- 是否在控制台输出sql语句 -->
<prop key="hibernate.show_sql">${hibernate.showSQL}</prop>
<!-- 是否在控制台格式化sql语句 -->
<prop key="hibernate.format_sql">${hibernate.formatSQL}</prop>
<!-- 自动创建修改表 -->
<!-- <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl}</prop> -->
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">classpath:ehcache-hibernate-local.xml</prop>
<prop key="hibernate.c3p0.max_statements">50</prop>
</props>
</property>
<property name="packagesToScan">
<value></value>
</property>
</bean>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询