当前位置:   article > 正文

关于Tomcat启动项目war包未更新问题_为什么java war包不会自动更新

为什么java war包不会自动更新

最近接手了一个比较老的一个项目,是通过外部引入Tomcat来进行启动,然后项目中的定时任务也是使用的Spring的Quartz,然后要加一个定时任务,毕竟是接手的项目,一边CV,一边看着Spring的文档。不能白白的抄,要抄的明白嘛。然后在运行的时候突然就发现加的定时任务就没有生效。

代码如下:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

	<!-- 每天2点处理百世仓出库单并在早上8点发送商品出库短信提醒 -->
	<bean id="terminalSurverllant5" class="cn.vcu.job.StockTaskServiceJob"></bean>
	
	<!-- 凌晨2点同步百世仓出库数据 -->
	<bean id="jobtask21"  class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<property name="targetObject">
			<ref bean="terminalSurverllant5" />
		</property>
		<property name="targetMethod">
			<value>shortMessage</value>
		</property>
	</bean>
	
	<!-- 2点处理百世仓出库数据 -->
	<bean id="doTime21" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail">
			<ref bean="jobtask21" />
		</property>
		<property name="cronExpression">
			<value>0 0 12 * * ?</value>
		</property>
	</bean>
	
<bean id="quartzInterceptor" class="cn.vcu.web.interceptor.QuartzInterceptor"/>

    <bean id="quartzProxy" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
          <property name="beanNames">
              <list>
                   <value>terminalSurverllant</value>
              </list>
         </property>
         <property name="interceptorNames">
              <list>
                   <value>quartzInterceptor</value>
              </list>
         </property>
    </bean>	
<!--  profile="test,online" -->
	  <beans profile="test,online">	
		<bean id="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
			<property name="triggers">
				<list>
					<ref bean="doTime21" />
				</list>
			</property>
		</bean>
	 </beans>
	 <beans profile="dev">	
		<bean id="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
			<property name="triggers">
				<list>
					<ref bean="doTime21" />
				</list>
			</property>
		</bean>
	 </beans>
</beans>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62

对于定时任务的代码我就不做过多的赘述:可以点击参考Spring官网

因为自己也确信自己的代码没有问题,于是就在排查,就别人已经好用的定时任务注释点,然后发现代码注释了,竟然也能执行。 就知道是war包没有更新的原因。其实本可以通过maven重新编译就行。但是每次编译也很费劲。于是就从tomcat里下文章。

直到我看到了这里,如图圈中的地方。
只有打钩,就会在项目对应的目录生成war包。反之,如果不打勾“Include in project build”,那么生成项目(Ctrl+F9)的时候就不会生成war包
在这里插入图片描述

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号