Tomcat java ¶¨Ê±ÈÎÎñ
Á½¸ötomcat Java¶¨Ê±ÈÎÎñµÄÀý×Ó
ÀýÒ»£º
±¾ÀýÒÀ¾ÝJava×ÔÉíÌṩµÄ½Ó¿ÚʵÏÖ£¬Í¨¹ý¼àÌýÆ÷£¨Listener£©ºÍ¶¨Ê±Æ÷£¨Timer£©¶¨Ê±Ö´ÐÐij¸öÈÎÎñ£¨Task£©¡£
רҵµÄ¿ªÔ´¹¤¾ß¿É²Î¿¼Quartz£ºhttp://www.opensymphony.com/quartz/
MyListener£º
import
java.util.Timer;
import
javax.servlet.ServletContextEvent;
import
javax.servlet.ServletContextListener;
public
class
MyListener
implements
ServletContextListener {
private
Timer timer
=
null
;
public
void
contextInitialized(ServletContextEvent event) {
timer
=
new
Timer(
true
);
//
ÉèÖÃÈÎÎñ¼Æ»®£¬Æô¶¯ºÍ¼ä¸ôʱ¼ä
timer.schedule(
new
MyTask(),
0
,
86400000
);
}
public
void
contextDestroyed(ServletContextEvent event) {
timer.cancel();
}
}
MyTask£º
import
java.util.TimerTask;
public
class
MyTask
extends
TimerTask {
public
void
run() {
//
System.out.println("call at " + (new Date()));
//
TODO ´Ë´¦Ìí¼Ó¾ßÌåÈÎÎñ´úÂë
}
}
web.xmlÅäÖãº
<
listener
>
<
listener-class
>
com.fastunit.samples.listener.MyListener
</
listener-class
>
</
listener
>
Àý¶þ
ÈçºÎÔÚWeb¹¤³ÌÖÐʵÏÖÈÎÎñ¼Æ»®µ÷¶È
ÏÂÃæ¾ÍServletÕìÌýÆ÷½áºÏJava¶¨Ê±Æ÷À´½²ÊöÕû¸öʵÏÖ¹ý³Ì¡£ÒªÔËÓÃServletÕìÌýÆ÷ÐèҪʵÏÖ
javax.servlet.ServletContextListener½Ó¿Ú£¬Í¬Ê±ÊµÏÖËüµÄ
contextInitialized(ServletContextEvent
event)ºÍcontextDestroyed(ServletContextEvent
event)Á½¸ö½Ó¿Úº¯Êý¡£¿¼ÂǶ¨
Ïà¹ØÎĵµ£º
µ±³ÌÐòµÄij¸öÄ£¿é±»µ÷ÓõÄʱ¿Ì²»È·¶¨£¬¾ÍÀàËÆÓڵȴýij¸öʼþµÄ·¢Éú¡£Õâʱ£¬¿ÉÒÔ¶¨Òå×Ô¼ºµÄʼþ½øÐÐÏàÓ¦µÄ´¦Àí¡£±ÈÈ磬µÈ´ýÓû§µÄÒ»´ÎÊäÈëµÈ¡£JavaµÄʼþÄ£ÐÍÒÀÀµÓÚίÍУ¬Í¨¹ý»Øµ÷·½·¨½øÐÐÏàÓ¦µÄʼþ´¦Àí¡£ÔÚʼþÔ´ÖУ¬»áÓÐfireXXXEvent()¾ÍÊǼ¤»îÏàÓ¦µÄʼþ£¬ÆäÖлá±éÀúʼþÔ´µÄ¼àÌýÆ ......
Ù¡Ç¿ http://blog.csdn.net/microtong
OakCMSÄÚÈݹÜÀíϵͳ http://www.oakcms.cn http://www.oakcms.net
Ò»Ôª¶þ´Î·½³Ìax2+bx+c=0£¬ÊäÈëa,b,cÈý¸öϵÊý£¬Çó½â·½³Ì£¬½á¹ûÓÐÈýÖÖÇé¿ö£ºÁ½¸öʵÊý¸ù¡¢Ò»¸öʵÊý¸ù¡¢Á½¸ö¸´Êý¸ù¡£
/**
* Equation.java
*/
package cn.edu.uibe.oop;
/**
* ¼ÆËã ......
×¢£º±¾ÎÄת×Ôhttp://lavasoft.blog.51cto.com µÄJavaÐéÄâ»ú£¨JVM£©²ÎÊýÅäÖÃ˵Ã÷£¬×÷Ϊ×Ô¼ºÑ§Ï°Óá£
JavaÐéÄâ»ú£¨JVM£©²ÎÊýÅäÖÃ˵Ã÷
ÔÚJava¡¢J2EE´óÐÍÓ¦ÓÃÖУ¬JVM·Ç±ê×¼²ÎÊýµÄÅäÖÃÖ±½Ó¹Øϵµ½Õû¸öϵͳµÄÐÔÄÜ¡£
JVM·Ç±ê×¼²ÎÊýÖ¸µÄÊÇJVMµ×²ãµÄһЩÅäÖòÎÊý£¬ÕâЩ²ÎÊýÔÚÒ»°ã¿ª·¢ÖÐĬÈϼ´¿É£¬²»ÐèÒªÈκÎÅäÖᣵ«ÊÇÔÚÉú ......
ʹÓÃJava³ÌÐò´ÓÊý¾Ý¿âÖвéѯ´óÁ¿µÄÊý¾ÝʱÈÝÒ׳öÏÖÒì³£:
java.lang.OutOfMemoryError: Java heap space
ÔÚJVMÖÐÈç¹û98£¥µÄʱ¼äÊÇÓÃÓÚGCÇÒ¿ÉÓÃµÄ Heap size ²»×ã2£¥µÄʱºò½«Å׳ö´ËÒì³£ÐÅÏ¢¡£
»¹ÓÐʹÓÃjxl¶ÁдexcelÎļþʱ£¬Í¬Ê±¶ÁÈëËùÓмǼ£¬Ò²ÈÝÒ׳öÏÖÕâ¸öÎÊÌâ¡£
JVM¶ÑµÄÉèÖÃÊÇÖ¸java³ÌÐòÔËÐйý³ÌÖÐJVM¿ÉÒÔµ÷ÅäʹÓõÄÄÚ ......
´Ó×î³£¹æµÄ·Ö²ã½á¹¹À´Ëµ£¬ÏµÍ³²ã´Î´ÓÉϵ½ÏÂÒÀ´ÎΪ£º
±íÏֲ㣺Ö÷ÒªÊÇ¿Í»§¶ËµÄչʾ¡£
·þÎñ²ã£ºÖ±½ÓΪ¿Í»§¶ËÌṩµÄ·þÎñ»ò¹¦ÄÜ¡£Ò²ÊÇϵͳËùÄܶÔÍâÌṩµÄ¹¦ÄÜ¡£
ÁìÓò²ã£ºÏµÍ³ÄÚµÄÁìÓò»î¶¯¡£
DAO²ã£ºÊý¾Ý·ÃÎʶÔÏó£¬Í¨¹ýÁìÓòʵÌå¶ÔÏóÀ´²Ù×÷Êý¾Ý¿â¡£
ÆäÖÐÓÐЩָµ¼ÔÔò£º
& ......