下面是applicationContext.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"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:oscache="http://www.springmodules.org/schema/oscache"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springmodules.org/schema/oscache http://www.springmodules.org/schema/cache/springmodules-oscache.xsd"> <!-- JDBC参数配置 -->
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
lazy-init="true">
<property name="systemPropertiesModeName"
value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<value>classpath:properties/jdbc.properties</value>
</list>
</property>
</bean> <!-- 数据源配置 -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<!-- 设置JDBC驱动名称 -->
<property name="driverClassName" value="${jdbc.driver}" />
<!-- 设置JDBC连接URL -->
<property name="url" value="${jdbc.url}" />
<!-- 设置数据库用户名 -->
<property name="username" value="${jdbc.username}" />
<!-- 设置数据库密码 -->
<property name="password" value="${jdbc.password}" />
<!-- 设置连接池初始值 -->
<property name="initialSize" value="5" />
<!-- 设置连接池最大值 -->
<property name="maxActive" value="100" />
<!-- 设置连接池最小空闲值 -->
<property name="minIdle" value="20" />
<!-- 设置连接池最大空闲值 -->
<property name="maxIdle" value="50" />
<!-- 空闲时测试连接,避免关闭 -->
<property name="testWhileIdle" value="true" />
<!-- 测试语句 -->
<property name="validationQuery"
value="select username from admin limit 1">
</property>
</bean> <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<!-- 配置Hibernate拦截器,自动填充数据的插入、更新时间 -->
<property name="entityInterceptor" ref="entityInterceptor" />
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<value>
<!-- 设置数据库方言 -->
hibernate.dialect=${hibernate.dialect}
<!-- 设置自动创建|更新|验证数据库表结构-->
hibernate.hbm2ddl.auto=update
<!-- 输出SQL语句到控制台 -->
hibernate.show_sql=${hibernate.show_sql}
<!-- 格式化输出到控制台的SQL语句 -->
hibernate.format_sql=${hibernate.format_sql}
<!-- 是否开启二级缓存 -->
hibernate.cache.use_second_level_cache=false
<!-- 配置二级缓存产品 -->
hibernate.cache.provider_class=org.hibernate.cache.OSCacheProvider
<!-- 是否开启查询缓存 -->
hibernate.cache.use_query_cache=false
<!-- 数据库批量查询数 -->
hibernate.jdbc.fetch_size=1000
<!-- 数据库批量更新数 -->
hibernate.jdbc.batch_size=1000
</value>
</property> <property name="packagesToScan">
<list>
<value>net.shopxx.admin.entity</value>
<value>net.shopxx.cms.entity</value>
<value>net.shopxx.mbr.entity</value>
<value>net.shopxx.shop.entity</value>
<value>net.shopxx.teambuy.entity</value>
<value>net.shopxx.play.entity</value>
<value>net.shopxx.trip.entity</value>
</list>
</property>
</bean> <!-- 缓存配置 -->
<oscache:config
configLocation="classpath:properties/oscache.properties"
id="cacheProvider" />
<oscache:annotations providerId="cacheProvider">
<oscache:caching id="caching" cronExpression="0 1 * * *"
refreshPeriod="86400" />
<oscache:flushing id="flushing" />
</oscache:annotations> <bean id="cacheManager"
class="org.springmodules.cache.provider.oscache.OsCacheManagerFactoryBean">
<property name="configLocation"
value="classpath:properties/oscache.properties" />
</bean> <!-- 设置需要进行Spring注解扫描的类包 -->
<context:component-scan base-package="net.shopxx" /> <!-- 使用AspectJ方式配置AOP -->
<aop:aspectj-autoproxy proxy-target-class="true" />
<aop:config proxy-target-class="true" /> <!-- 使用注解方式定义事务 -->
<tx:annotation-driven proxy-target-class="true"
transaction-manager="transactionManager" /> <!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean> <!-- 配置事务传播特性 -->
<tx:advice id="transactionAdvice"
transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="get*" read-only="true" />
<tx:method name="load*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice> <!-- 配置哪些类的哪些方法参与事务 -->
<aop:config>
<aop:advisor
pointcut="execution(* net.shopxx.*.service..*.*(..))"
advice-ref="transactionAdvice" />
</aop:config> <!-- 配置freeerManager -->
<bean id="freeerManager"
class="org.apache.struts2.views.freeer.FreeerManager" /> <!-- 配置JCaptcha验证码功能 -->
<bean id="captchaService"
class="com.octo.captcha.service.image.DefaultManageableImageCaptchaService">
<property name="captchaEngine">
<bean class="net.shopxx.common.captcha.JCaptchaEngine" />
</property>
<!-- 验证码过期时间 -->
<property name="minGuarantedStorageDelayInSeconds" value="600" />
</bean> <!-- 重建索引配置
<bean id="indexBuilder" class="net.shopxx.common.CompassIndexBuilder">
<property name="compassGps" ref="compassGps" />
<property name="lazyTime" value="30" />
</bean> --> <!-- SMTP邮件服务配置 -->
<bean id="javaMailSender"
class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.timeout">25000</prop>
<!-- SSL连接配置 -->
<!--
<prop key="mail.smtp.starttls.enable">true</prop>  
<prop key="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
-->
</props>
</property>
</bean> <!-- SMTP邮件异步发送 -->
<bean id="taskExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<!-- 核心线程数 -->
<property name="corePoolSize" value="10" />
<!-- 最大线程数 -->
<property name="maxPoolSize" value="50" />
<!-- 最大队列数 -->
<property name="queueCapacity" value="10000" />
<!-- 线程池维护线程所允许的空闲时间 -->
<property name="keepAliveSeconds" value="60" />
</bean></beans>
请求高手帮助,谢谢

解决方案 »

  1.   

    Could not resolve placeholder 'jdbc.driver'
    应该是驱动名称问题
    检查下你的properties/jdbc.properties
      

  2.   

    jdbc.driver=com.mysql.jdbc.Driver
    jdbc.url=jdbc\:mysql\://localhost\:3306/coyeexx?useUnicode\=true&characterEncoding\=UTF-8
    jdbc.username=root
    jdbc.password=coyox
    hibernate.dialect=org.hibernate.dialect.MySQLDialect
    hibernate.show_sql=true
    hibernate.format_sql=false
      

  3.   

    http://topic.csdn.net/u/20110719/23/0b7e2ae9-255f-4d09-b1de-d221115575b6.html2楼的师傅,帮我解决这个问题,谢谢了!
      

  4.   

    你的lib文件夹有mysql驱动包吗?这个是必须的.