0. 假设已配置好 SSM 环境
1. 配置文件
有划分配置文件的话建议添加在 spring-service.xml
中,没有的话就放在可以生效的地方
spring-service.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/task
https://www.springframework.org/schema/task/spring-task.xsd">
<!-- 扫描 service 下的包 -->
<!-- service 为定时任务所在的包 -->
<!-- utils 为 Redis 工具类所在的包 -->
<context:component-scan base-package="com.qg.service"/>
<context:component-scan base-package="com.qg.utils"/>