Java 如何在struts eclipse中使用thread或cronjob在特定时间自动发送每日消息?

Java 如何在struts eclipse中使用thread或cronjob在特定时间自动发送每日消息?,java,eclipse,Java,Eclipse,请帮助我解决这个问题,我将在eclipse中的特定时间每天应用发送自动消息,但我感到困惑,所以请给我建议使用Quartz 2.1.5 API <!--Maven Dependency--> <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifactId> <version>2.1.5&l

请帮助我解决这个问题,我将在eclipse中的特定时间每天应用发送自动消息,但我感到困惑,所以请给我建议使用Quartz 2.1.5 API

<!--Maven Dependency-->
<dependency>
    <groupId>org.quartz-scheduler</groupId>
    <artifactId>quartz</artifactId>
    <version>2.1.5</version>
</dependency>'
您的调度程序方法如下所示

 HelloJob.java

    import org.quartz.Job;
    import org.quartz.JobExecutionContext;
    import org.quartz.JobExecutionException;

    /**
     * This class defines a quartz job.
     * @author Prabhakar Kumar
     */
    public class HelloJob implements Job{
        public void execute(JobExecutionContext context)
                throws JobExecutionException {
           //Here is your code in this method(Your Logic)
            System.out.println("Hello World.");      
        }
    }
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >   <web-app> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng. filter.StrutsPrepareAndExecuteFilter </filter-class> </filter>   <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>   <listener> <listener-class> com.javawithease.business.QuartzListener </listener-class> </listener>   </web-app>
Web.xml看起来像

 HelloJob.java

    import org.quartz.Job;
    import org.quartz.JobExecutionContext;
    import org.quartz.JobExecutionException;

    /**
     * This class defines a quartz job.
     * @author Prabhakar Kumar
     */
    public class HelloJob implements Job{
        public void execute(JobExecutionContext context)
                throws JobExecutionException {
           //Here is your code in this method(Your Logic)
            System.out.println("Hello World.");      
        }
    }
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >   <web-app> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng. filter.StrutsPrepareAndExecuteFilter </filter-class> </filter>   <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>   <listener> <listener-class> com.javawithease.business.QuartzListener </listener-class> </listener>   </web-app>
struts2 org.apache.struts2.dispatcher.ng。filter.StrutsPrepareAndExecuteFilter struts2/*com.javawithease.business.QuartzListener

使用调度程序