阿常先生 2011-08-31 12:01
浏览 325
已采纳

spring中管理timerTask配置文件正确,不执行代码,是否和其它配置有冲突?

<?xml version="1.0" encoding="UTF-8"?>

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd"
default-autowire="byName" default-lazy-init="true">

<description>define all the basic bean mappings</description>
<context:annotation-config />

<!-- jedis pool配置 -->
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
    <property name="maxActive" value="200" />
    <property name="maxIdle" value="10" />
    <property name="maxWait" value="1000" />
    <property name="testOnBorrow" value="true" />
</bean>

<!-- jedis pool配置 -->
<bean id="jedisPool" class="redis.clients.jedis.JedisPool">
    <constructor-arg index="0" ref="jedisPoolConfig" />
    <constructor-arg index="1" value="172.16.1.165"/>
    <constructor-arg index="2" value="6379"/>
</bean>
<!-- 配置所有的配置信息 -->
<bean id="constants" class="com.gozap.chouti.digg.core.commons.Constants">
  <property name="scoffPic" value="http://img.gozap.com/group1/M00/51/A1/wKgCIk5XCSSIAoY_AACjisrsXVs070.jpg.jpg"></property>
  <property name="rumorPic" value="http://img.gozap.com/group1/M00/4F/8A/wKgCIk5V7PyMX4vTAABYVNWWTQU258.jpg.jpg"></property>
  <property name="titleMaxLength" value="300"></property>
  <property name="urlMaxLength" value="512"></property>
</bean>

<!-- for properties files -->
<bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>classpath*:config/jdbc.properties</value>
        </list>
    </property>
</bean>

    <!-- 数据库连接池 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://172.16.1.153:3306/chouti_digg?useUnicode=true&amp;characterEncoding=UTF-8" />
    <property name="username" value="chouti_digg" />
    <property name="password" value="chouti" />
    <property name="defaultAutoCommit" value="true"></property>
</bean>

<!-- Mybatis's sqlSessionFactory config -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
    <property name="configLocation" value="classpath:ibatis/mybatis-config.xml"/>       
</bean>

<bean name="transactionManager"
    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"></property>
</bean>


<!-- 新榜榜单数据根据一定规则入热榜 -->
<bean id="choutiLinkNewToHot" class="com.gozap.chouti.digg.content.service.ChoutiLinkNewToHot">
</bean>

<!-- 配置spring定时器 -->


5000
5000

<!-- 启动spring定时器 -->




<!-- 启用事务 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="save*" propagation="REQUIRED" />
        <tx:method name="add*" propagation="REQUIRED" />
        <tx:method name="delete*" propagation="REQUIRED" />
        <tx:method name="update*" propagation="REQUIRED" />
    </tx:attributes>
</tx:advice>



/context:component-scan

<!-- Support @Transactional tag -->
<tx:annotation-driven />

<!-- scan  mappers and let them be autowired -->
<bean id="mapperConfig" class="org.mybatis.spring.mapper.MapperScannerConfigurer">       
    <property name="basePackage" value="com.gozap.chouti.digg.core.dao" />
</bean>
<!-- 激活annotation功能 -->
<context:annotation-config />
<!-- 激活annotation功能 -->
<context:spring-configured />

  • 写回答

1条回答 默认 最新

  • jep1983 2011-09-02 14:24
    关注

    ChoutiLinkNewToHot类写的对不对?如果是正确的,建议把spring的bean文件中和timertask不相关的bean去掉进行测试。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 机器学习教材中的例题询问
  • ¥15 求.net core 几款免费的pdf编辑器
  • ¥15 C# P/Invoke的效率问题
  • ¥20 thinkphp适配人大金仓问题
  • ¥20 Oracle替换.dbf文件后无法连接,如何解决?(相关搜索:数据库|死循环)
  • ¥15 数据库数据成问号了,前台查询正常,数据库查询是?号
  • ¥15 算法使用了tf-idf,用手肘图确定k值确定不了,第四轮廓系数又太小才有0.006088746097507285,如何解决?(相关搜索:数据处理)
  • ¥15 彩灯控制电路,会的加我QQ1482956179
  • ¥200 相机拍直接转存到电脑上 立拍立穿无线局域网传
  • ¥15 (关键词-电路设计)