Struts2.3.14+Spring3.2+Hibernate4.2.1配置文件头问题

Roy_zdc 2013-05-10 07:13:22
Struts2.3.14+Spring3.2+Hibernate4.2.1配置文件头问题
我的配置文件applicationContext-dataSource.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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:c3p0.properties</value>
</property>

</bean>

<!-- DataSource -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass">
<value>${oracle.driverClass}</value>
</property>
<property name="jdbcUrl">
<value>${oracle.jdbcUrl}</value>
</property>
<property name="user">
<value>${oracle.user}</value>
</property>
<property name="password">
<value>${oracle.password}</value>
</property>
<property name="minPoolSize">
<value>${c3p0.minPoolSize}</value>
</property>
<property name="maxPoolSize">
<value>${c3p0.maxPoolSize}</value>
</property>
<property name="initialPoolSize">
<value>${c3p0.initialPoolSize}</value>
</property>
<property name="maxIdleTime">
<value>${c3p0.maxIdleTime}</value>
</property>
<property name="maxStatements">
<value>${c3p0.maxStatements}</value>
</property>
<property name="acquireIncrement">
<value>${c3p0.acquireIncrement}</value>
</property>
<property name="acquireRetryAttempts">
<value>${c3p0.acquireRetryAttempts}</value>
</property>
<property name="acquireRetryDelay">
<value>${c3p0.acquireRetryDelay}</value>
</property>
<property name="testConnectionOnCheckin">
<value>${c3p0.testConnectionOnCheckin}</value>
</property>
<property name="automaticTestTable">
<value>${c3p0.automaticTestTable}</value>
</property>
<property name="idleConnectionTestPeriod">
<value>${c3p0.idleConnectionTestPeriod}</value>
</property>
<property name="checkoutTimeout">
<value>${c3p0.checkoutTimeout}</value>
</property>
</bean>


<!-- SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>

<property name="hibernateProperties">
<props>
<!-- 指定数据库方言 -->
<prop key="hibernate.dialect">
${hibernate.oracle.dialect}
</prop>

<!-- 是否在日志中输出所有Hibernate与数据库交互的SQL语句 -->
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<!-- 是否在日志中输出的SQL 语句格式化成易读形式 -->
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>
<!-- Fetch Size 是设定JDBC的Statement读取数据的时候每次从数据库中取出的记录条数,一般设置为30、50、100。
Oracle数据库的JDBC驱动默认的Fetch Size=15,设置Fetch Size设置为:30、50,性能会有明显提升,如果继续增大, 超出100,性能提升不明显,反而会消耗内存。 -->
<prop key="hibernate.jdbc.fatch_size">${hibernate.jdbc.fatch_size}</prop>
<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>

<!-- Hibernate4 这里和Hibernate3不一样 要特别注意!!!-->
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.EhCacheRegionFactory</property>
<!-- Hibernate3-->
<!-- <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop> -->

</props>
</property>
<!-- hbm映射文件配置mappingResources -->
<property name="mappingResources">
<list>
<value>com/ccland/model/FileStorage.hbm.xml</value>
</list>
</property>
</bean>
</beans>

产生的错误如下:

2013-5-10 19:02:50 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Users\zhongdc\AppData\Local\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_1.6.0.013\bin;C:\tomcat7\bin
2013-5-10 19:02:51 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-bio-8080"]
2013-5-10 19:02:51 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-bio-8009"]
2013-5-10 19:02:51 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 684 ms
2013-5-10 19:02:51 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
2013-5-10 19:02:51 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.16
2013-5-10 19:02:51 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2013-5-10 19:02:51 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory examples
2013-5-10 19:02:51 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2013-5-10 19:02:51 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2013-5-10 19:02:51 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@6745b9')
2013-5-10 19:02:51 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory host-manager
2013-5-10 19:02:52 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory manager
2013-5-10 19:02:52 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2013-5-10 19:02:52 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory WebServiceDemo
2013-5-10 19:04:13 org.apache.catalina.core.ApplicationContext log
信息: No Spring WebApplicationInitializer types detected on classpath
2013-5-10 19:04:13 org.apache.catalina.core.ApplicationContext log
信息: Set web app root system property: 'webApp.root' = [C:\tomcat7\webapps\WebServiceDemo\]
2013-5-10 19:04:14 org.apache.catalina.core.ApplicationContext log
信息: Initializing log4j from [C:\tomcat7\webapps\WebServiceDemo\WEB-INF\classes\log4j.properties]
2013-5-10 19:04:14 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
19:04:14,362 INFO ContextLoader:273 - Root WebApplicationContext: initialization started
19:04:14,432 INFO XmlWebApplicationContext:510 - Refreshing Root WebApplicationContext: startup date [Fri May 10 19:04:14 CST 2013]; root of context hierarchy
19:04:14,479 INFO XmlBeanDefinitionReader:315 - Loading XML bean definitions from class path resource [applicationContext-dataSource.xml]
19:04:14,664 ERROR ContextLoader:319 - Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 95 in XML document from class path resource [applicationContext-dataSource.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'property'. One of '{"http://www.springframework.org/schema/beans":prop}' is expected.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'property'. One of '{"http://www.springframework.org/schema/beans":prop}' is expected.


看这意思,新的规范是不支持标签<prop></prop>了,不知道该如何写,或者头文件该如何修改?

...全文
180 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Roy_zdc 2013-05-13
  • 打赏
  • 举报
回复
是我自己范了一个低级错误
<!-- Hibernate4 这里和Hibernate3不一样 要特别注意!!!--><property name="hibernate.cache.region.factory_class">org.hibernate.cache.EhCacheRegionFactory</property>
正确的:
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.EhCacheRegionFactory</prop>
小丑哥_V5 2013-05-10
  • 打赏
  • 举报
回复
请参考我的基于spring,security的开源项目 http://blog.csdn.net/shadowsick

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧