Spring3 에서 Scheduled 사용하는 방법이다.
우선 추가해야 될 사항으로 xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation= 에는 http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd 을 추가해야 한다.
그리고 마지막으로는 아래의 것을 추가한다.
<task:annotation-driven/>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />
<task:annotation-driven/>
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="패키지" />
</beans:beans>
사용방법
@Scheduled(cron = "0 2/5 * * * *") public void harvestStatus() { ~~~~~~~~~~ }
'Development > Web & Server' 카테고리의 다른 글
Google Custom Search 사용하기 (0) | 2014.09.04 |
---|---|
Google Charts (0) | 2014.08.18 |
Hibernate4 org.hibernate.MappingException: Unknown entity (0) | 2014.06.23 |
Hibernate Incorrect datetime value (0) | 2014.04.24 |
org.hibernate.hibernateexception identifier of an instance of was altered from to (0) | 2014.04.22 |