startdemo.sh

nohup /home/jdk1.6.0_14/bin/java -Dfile.encoding=GBK  -Xms200m -Xmx400m -classpath "/home/icehome/search2010_demo/WEB-INF/classes" -Djava.ext.dirs=/home/icehome/search2010_demo/WEB-INF/lib com.yesky.wstsearch.common.FileUtil.File2DocumentUtils &

nohup 命令
jdk路径
class路径
lib路径
方法全路径






监听器方法:
package com.yesky.servlet;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.yesky.wstsearch.DBSpider;

public class MyServletContextListener implements ServletContextListener{
    ApplicationContext context
=new ClassPathXmlApplicationContext("classpath*:**//application*.xml");
    DBSpider db
=(DBSpider) context.getBean("dbSpider");

 
public void contextDestroyed(ServletContextEvent arg0)
 {

 }

 
public void contextInitialized(ServletContextEvent arg0)
 {
  System.out.println(
" 开始");
  
try{
     db.Run();
  }
  
catch(Exception e)
  {
   System.out.println(
"结束");
   e.printStackTrace();
  }
 }
}

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
    xmlns
="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation
="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <welcome-file-list>
    
<welcome-file>index.jsp</welcome-file>
  
</welcome-file-list>
    
<listener>
  
<listener-class>com.yesky.servlet.MyServletContextListener</listener-class>
 
</listener>
</web-app>