ssm 框架,在本地环境下完美运行,在服务器上定时器执行两次

此处为 spring-mybatis.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:p="http://www.springframework.org/schema/p"  
    xmlns:context="http://www.springframework.org/schema/context"  
    xmlns:mvc="http://www.springframework.org/schema/mvc"  
        xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans    
                        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd    
                        http://www.springframework.org/schema/context    
                        http://www.springframework.org/schema/context/spring-context-4.0.xsd    
                        http://www.springframework.org/schema/mvc    
                        http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
                        http://www.springframework.org/schema/aop
                        http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">  
    <!-- 自动扫描 -->  



<!-- 激活自动代理功能 -->

        <!-- 引入配置文件 -->  
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"  
        destroy-method="close">  
        <property name="driverClassName" value="${jdbc.driver}" />  
        <property name="url" value="${jdbc.url}" />  
        <property name="username" value="${jdbc.username}" />  
        <property name="password" value="${jdbc.password}" />  
        <!-- 初始化连接大小 -->  
        <property name="initialSize" value="${initialSize}"></property>  
        <!-- 连接池最大数量 -->  
        <property name="maxActive" value="${maxActive}"></property>  
        <!-- 连接池最大空闲 -->  
        <property name="maxIdle" value="${maxIdle}"></property>  
        <!-- 连接池最小空闲 -->  
        <property name="minIdle" value="${minIdle}"></property>  
        <!-- 获取连接最大等待时间 -->  
        <property name="maxWait" value="${maxWait}"></property>  
    </bean>  

    <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->  
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  
        <property name="dataSource" ref="dataSource" />  
        <!-- 自动扫描mapping.xml文件 -->  
        <property name="mapperLocations" value="classpath:com/bls/mp/mapping/*.xml"></property>  
    </bean>  

    <!-- DAO接口所在包名,Spring会自动查找其下的类 -->  
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  
        <property name="basePackage" value="com.bls.mp.dao" />  
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>  
    </bean>  

    <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->  
    <bean id="transactionManager"  
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
        <property name="dataSource" ref="dataSource" />  
    </bean>  



</beans>

此处为 spring-mvc.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:p="http://www.springframework.org/schema/p"  
    xmlns:context="http://www.springframework.org/schema/context"  
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:task="http://www.springframework.org/schema/task"  
    xsi:schemaLocation="http://www.springframework.org/schema/beans    
                        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd    
                        http://www.springframework.org/schema/context    
                        http://www.springframework.org/schema/context/spring-context-4.0.xsd    
                        http://www.springframework.org/schema/mvc    
                        http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
                        http://www.springframework.org/schema/task
                        http://www.springframework.org/schema/task/spring-task-4.0.xsd" >  
    <!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 -->  
    <context:component-scan base-package="com.bls.mp.*"/>  

    <!--避免IE执行AJAX时,返回JSON出现下载文件 -->  
    <bean id="mappingJacksonHttpMessageConverter"  
        class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">  
        <property name="supportedMediaTypes">  
            <list>  
                <value>text/html;charset=UTF-8</value>  
            </list>  
        </property>  
    </bean>  
      <!-- <bean id="thirdDataService" class="com.bls.mp.service.impl.ThirdDataServiceImpl"/>-->  
    <bean class="com.bls.mp.common.SpringTool"/>

    <!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 -->  
 <!-- <bean  
        class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">  
        <property name="messageConverters">  
            <list>  
                <ref bean="mappingJacksonHttpMessageConverter" /> JSON转换器  
            </list>  
        </property>  
    </bean>-->  
    <!-- 定义跳转的文件的前后缀 ,视图模式配置-->  
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
        <!-- 这里的配置我的理解是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 -->  
        <property name="prefix" value="/WEB-INF/resources/jsp/" />  
        <property name="suffix" value=".jsp" />  
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
    </bean>  

    <!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 -->  
    <bean id="multipartResolver"    
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">    
        <!-- 默认编码 -->  
        <property name="defaultEncoding" value="utf-8" />    
        <!-- 文件大小最大值 -->  
        <property name="maxUploadSize" value="10485760000" />    
        <!-- 内存中的最大值 -->  
        <property name="maxInMemorySize" value="40960" />    
    </bean>   
    <!-- 全局异常处理器 -->
    <bean class="com.bls.mp.common.exception.CustomExceptionResolver"></bean>
  <mvc:annotation-driven/>
  <!-- 拦截器配置 -->
  <mvc:interceptors>
    <mvc:interceptor>
    <mvc:mapping path="/setadmin"/>
    <!--<mvc:mapping path="/user/userList"/> -->
    <mvc:mapping path="/Blocker"/>
    <mvc:mapping path="/grouponteam/grouponRanking"/> 
    <mvc:mapping path="/grouponteam/arriverTime"/> 
    <mvc:mapping path="/grouponteam/paging"/>
    <mvc:mapping path="/grouponteam/conditionGrouponT"/>
    <mvc:mapping path="/hospital/hospitalInfo"/>
    <mvc:mapping path="/hospital/setting"/>
    <mvc:mapping path="/hospital/orderdetails"/>
    <mvc:mapping path="/grouponteam/grouponTeamCountAndMoney"/>
    <mvc:mapping path="/grouponteam/OrderRefundList"/>
    <mvc:mapping path="/grouponteam/orderdetails"/>
    <mvc:mapping path="/grouponteam/paging"/>
    <mvc:mapping path="/grouponteam/conditionGrouponT"/>
    <mvc:mapping path="/grouponteam/grouponRanking"/>
    <mvc:mapping path="/grouponteam/arriverTime"/>
    <mvc:mapping path="/grouponteam/grouponTeamCountAndMoney"/>
    <mvc:mapping path="/imguoload"/>
    <mvc:mapping path="/imguoloads"/>
    <mvc:mapping path="/uploadFile"/>
    <mvc:mapping path="/uploadCenter"/>
    <mvc:mapping path="/onTheShelves"/>
    <mvc:mapping path="/updateTheRecommended"/>
    <mvc:mapping path="/deleteByGoods"/>
    <mvc:mapping path="/restoreGoods"/>
    <mvc:mapping path="/goods/goodslist"/>
    <mvc:mapping path="/goods/hasBeenOn"/>
    <mvc:mapping path="/goods/NotOn"/>
    <mvc:mapping path="/goods/RecycleBin"/>
    <mvc:mapping path="/goods/searchName"/>
    <mvc:mapping path="/goods/goodsdiy"/>

    <mvc:mapping path="/upload/uploadFile"/>
    <mvc:mapping path="/CreateClassImg"/>
    <mvc:mapping path="/imglist"/>

    <mvc:mapping path="/up_img"/>
    <mvc:mapping path="/moveImg"/>
    <mvc:mapping path="/deleteImg"/>

    <mvc:mapping path="/template/templateURL"/>
    <mvc:mapping path="/template/templateParentAll"/>
    <mvc:mapping path="/template/templatAll"/>
    <mvc:mapping path="/template/changeT"/>
    <mvc:mapping path="/template/deleteT"/>

    <mvc:mapping path="/TemplateMsg/addTemplateMsg"/>
    <mvc:mapping path="/TemplateMsg/templateMsgList"/>
    <mvc:mapping path="/TemplateMsg/templateSendlist"/>
    <mvc:mapping path="/TemplateMsg/TemplateSendMsg"/>
    <mvc:mapping path="/TemplateMsg/updataPTID"/>
    <mvc:mapping path="/TemplateMsg/deleteMB"/>

    <mvc:mapping path="/ThirdData/getdata"/>
    <mvc:mapping path="/ThirdData/updata"/>

    <mvc:mapping path="/setMoney/setMoneyList"/>
    <mvc:mapping path="/setMoney/setArriveMoney"/>
    <mvc:mapping path="/setMoney/checkfileCert"/>
    <mvc:mapping path="/setMoney/SetMoneyType"/>

    <mvc:mapping path="/user/userlists"/>
    <mvc:mapping path="/user/uOpenId"/>

    <mvc:mapping path="/visitor/theAlmostMoon"/>
    <mvc:mapping path="/visitor/SixAlmostMoon"/>
    <mvc:mapping path="/visitor/tops"/>


    <mvc:mapping path="/weixin/REFUND"/>




    <bean class="com.bls.mp.interceptor.AuthInterceptor"></bean>
    </mvc:interceptor>
  </mvc:interceptors>
  <task:annotation-driven/>
  <!-- 配置访问静态文件  -->
  <mvc:default-servlet-handler/>
  <mvc:resources location="/images/" mapping="/images/**"/>
  <mvc:resources location="/WEB-INF/js/" mapping="/js/**"/>
  <mvc:resources location="/WEB-INF/resources/jsp/" mapping="/jsp/**"/>
  <mvc:resources location="/WEB-INF/resources/css/" mapping="/css/**"/>
</beans>  

此处为web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>Archetype Created Web Application</display-name>

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring-redis.xml,classpath:spring-mybatis.xml</param-value>
  </context-param>
  <filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <async-supported>true</async-supported>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <filter>
        <filter-name>CORSFilter</filter-name>
        <filter-class>com.bls.mp.common.MyFilter</filter-class>
        <init-param>
            <param-name>excludedPages</param-name>
            <param-value>/UserAuthServlet</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>CORSFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <listener>
    <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>SpringMVC</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:spring-mvc.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    <async-supported>true</async-supported>
  </servlet>
  <servlet-mapping>
    <servlet-name>SpringMVC</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>/index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

此处为tomcat 配置

<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
  <GlobalNamingResources>
    <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase" />
  </GlobalNamingResources>
  <Service name="Catalina">
    <Connector connectionTimeout="20000" maxPostSize="0" port="8080" protocol="HTTP/1.1" redirectPort="8443" />
    <Connector maxPostSize="0" port="8009" protocol="AJP/1.3" redirectPort="8443" />
    <Engine defaultHost="localhost" name="Catalina">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase" />
      </Realm>

      <Host autoDeploy="true" name="yuming.cn" appBase="" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
        <Context crossContext="true" docBase="/www/server/tomcat/webapps/xiangmu" path="" reloadable="true" />
      </Host>
    </Engine>
  </Service>
</Server>

spring-radis.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:p="http://www.springframework.org/schema/p"
          xmlns:tx="http://www.springframework.org/schema/tx"
          xmlns:context="http://www.springframework.org/schema/context"
          xsi:schemaLocation="
      http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-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/context
      http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:property-placeholder location="classpath:*.properties"/>
    <!--设置数据池-->
    <bean id="poolConfig"  class="redis.clients.jedis.JedisPoolConfig">
        <property name="maxIdle" value="${redis.maxIdle}"></property>
        <property name="minIdle" value="${redis.minIdle}"></property>
        <property name="maxTotal" value="${redis.maxTotal}"></property>
        <property name="maxWaitMillis" value="${redis.maxWaitMillis}"></property>
        <property name="testOnBorrow" value="${redis.testOnBorrow}"></property>
    </bean>
    <!--链接redis-->
    <bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
        <property name="hostName" value="${redis.host}"></property>
        <property name="port" value="${redis.port}"></property>
        <property name="password" value="${redis.password}"></property>
        <property name="poolConfig" ref="poolConfig"></property>
    </bean>

    <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" p:connection-factory-ref="connectionFactory" >
        <!--以下针对各种数据进行序列化方式的选择-->
        <property name="keySerializer">
            <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
        </property>
        <property name="valueSerializer">
            <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
        </property>
        <property name="hashKeySerializer">
            <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
        </property>
        <!--<property name="hashValueSerializer">
            <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
        </property>-->
    </bean>
</beans>

2个回答

spring-redis.xml配置呢

qq_44226361
思相见 今天这个问题又出现了,按照大哥说的办法,改了路径,行了,完美,多谢大哥
10 个月之前 回复
qq_44226361
思相见 回复思相见: 解决了,是里面for循环的问题
10 个月之前 回复
qq_44226361
思相见 我这边目前定时器运行一次,但是数据更新了两次,这是为什么。。。。
10 个月之前 回复
qq_44226361
思相见 回复武汉牛牛是tomcat目录,但是如果定位到其他文件项目还会不会启动?具体怎么操作,大哥详细解释下
10 个月之前 回复
jcy7523
武汉牛牛 回复思相见: appBase="",docBase="/www/server/tomcat/webapps/xiangmu",/www/server/tomcat,这个目录是不是tomcat所在目录,如果是,那就是重复加载了,请将docBase定位到其他目录
10 个月之前 回复
qq_44226361
思相见 麻烦看下。
10 个月之前 回复
qq_44226361
思相见 加了
10 个月之前 回复

你是不是做服务做集群啦?集群了俩台?一台执行一次

qq_44226361
思相见 没有没有
10 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐