第一步:DailyTask.java
package com.springinaction.quartz; import org.springframework.scheduling.quartz.QuartzJobBean; public class DailyTask extends QuartzJobBean { private HelloWorld helloWorld; public HelloWorld getHelloWorld() { return helloWorld; } public void setHelloWorld(HelloWorld helloWorld) { this.helloWorld = helloWorld; } protected void executeInternal(org.quartz.JobExecutionContext context) throws org.quartz.JobExecutionException { this.helloWorld.sayHello(); } }
第二步:HelloWorld.java
package com.springinaction.quartz; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class HelloWorld { public void sayHello() { Date now = Calendar.getInstance().getTime(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); System.out.println("Hello World! " + simpleDateFormat.format(now)); } }
第三步:Spring的配置文件springquartz.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> <bean id="helloWorld" class="com.springinaction.quartz.HelloWorld" /> <bean id="dailyRantEmailJob" class="org.springframework.scheduling.quartz.JobDetailBean"> <property name="jobClass" value="com.springinaction.quartz.DailyTask"></property> <property name="jobDataAsMap"> <map> <entry key="helloWorld" value-ref="helloWorld"></entry> </map> </property> </bean> <bean id="cronEmailTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail" ref="dailyRantEmailJob" /> <property name="cronExpression" value="0-59 0-59 0-23 * * ?" /> </bean> <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="cronEmailTrigger"/> </list> </property> </bean> </beans>
第四步:啓動Test.java
package com.springinaction.quartz; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Test { public static void main(String[] args) { new ClassPathXmlApplicationContext("springquartz.xml"); } }
異常的處理:
nested exception is java.lang.NoSuchMethodError: org.apache.commons.collections.SetUtils.orderedSet(Ljava/util/Set;)Ljava/util/Set; 出現這個異常的原因是:commons-collections.jar版本太低,可以到http://commons.apache.org/collections/下載最commons-collections-3.2.1-bin.tar.gz ,注意在user library中需要將這個jar包移到最前面,這樣就可以最先被引用。
如果想要閱讀源碼,首先要選擇版本,然後將源代碼下載到本地,導入idea中,話不多說,直接看步驟吧 這裏我選擇5版本, 下載源碼 默認是main分支,看想學習的分支,比如我切換到5版本,截圖如下: 2.安裝gradle 3
每篇一句 大魔王張怡寧:女兒,這堆金牌你拿去玩吧,但我的銀牌不能給你玩。你要想玩銀牌就去找你王浩叔叔吧,他那銀牌多 前言 爲了講述好Spring MVC最爲複雜的數據綁定這塊,我前面可謂是做足了功課,對此部分知識此處給小夥伴留一個學
前言 最近參與的項目中,接口中返回的日期格式不對,發現項目中配置了fastjson作爲spring的數據轉換器,於是使用了fastjson的字段格式化轉換註解 發現不起作用。這讓我很疑惑,然後在fastjson的相關代碼中打斷點發現請
本教程將引導您向現有的Web應用程序添加Spring安全策略,在本教程中您將學習如何: 搭建Spring安全策略 部署應用程序 MyEclipse v2023.1.2離線版下載 搭建Spring安全策略 1. 創建一個 scaf
作者:姬世文 背景介紹 RAG(Retrieval Augmented Generation) 檢索增強生成(RAG)是一種用於將數據與人工智能模型集成的技術。在 RAG 工作流程中,第一步將文檔數據加載到矢量數據庫(例如 Redis)中。
1-背景 後臺BFF層服務爲了SEO,涉及大量對底層數據的聚合,如果按照過程化編程,串行執行請求數據再聚合會造成很高的延遲,因此我們往往大量使用多線程技術並行化多個查詢,來減少單個請求的響應時間。 多線程一定程度上也能達成通過並行化提升
在這裏分享一下通過拖取 DataCube 代碼審計後發現的一些漏洞,包括前臺的文件上傳,信息泄露出賬號密碼,後臺的文件上傳。當然還有部分 SQL 注入漏洞,因爲 DataCube 採用的是 SQLite 的數據庫,所以SQL 注入相對來說顯
轉載自劉茫茫看山 問題背景 某天我們的租戶反饋數據庫連接缺少必要的驅動,我們通過日誌查看確實是缺少部分數據庫的驅動,因爲DolphinScheduler默認只帶了Oracle和MySQL的驅動,並且需要將pom文件中的test模式去掉纔可以
鴻蒙原生應用再新丁!新華社 入局鴻蒙 來自 #HarmonyOS# 微博5月27日消息 #鴻蒙千帆起#新華社客戶端完成鴻蒙原生應用核心版本開發,將實現不同使用場景下更加智能、精準、及時的要聞推送,以及主流價值的全場景覆蓋和高效傳播!與此同
記一次攻防演練中幸運的從若依弱口令到後臺getshell的過程和分析。 0x01 漏洞發現 首先,我會先把目標的二級域名拿去使用搜索引擎來搜索收集到包含這個目標二級域名的三級域名或者四級域名的網站。 這樣子可以快速的定位到你所要測試的漏洞
通過類之間的關係圖,讀懂spring boot原理 RequestBodyAdvice接口用於對Controller方法接收的請求體進行全局處理,可以在請求體被讀取之前或之後對請求體進行修改、包裝或添加一些額外的處理邏輯。下面是Req
鴻蒙原生應用再新丁!學習強國 入局鴻蒙 來自 #HarmonyOS# 微博5月23日消息 中央宣傳部宣傳輿情研究中心宣佈,將基於HarmonyOS NEXT鴻蒙星河版啓動“學習強國”App鴻蒙原生應用開發!“學習強國”App將爲鴻蒙生態帶
前言 在無線網絡技術不斷髮展的今天,Wi-Fi已經成爲了我們日常生活中不可或缺的一部分。無論是家庭娛樂、辦公還是在線遊戲,Wi-Fi都在提供着便捷的互聯網接入服務。然而,在安卓8.1後,爲了進一步延長安卓設備的待機時間。原生安卓(AO
鴻蒙原生應用再新丁!芒果TV 入局鴻蒙 來自 #HarmonyOS# 微博5月21日消息 深受年輕人喜愛的@芒果TV 宣佈完成鴻蒙原生應用Beta版開發🎉芒果TV獨家精品內容結合HarmonyOS NEXT創新能力,將爲用戶帶來更加便捷
有小夥伴們問到這個問題*簡單寫篇文章和大夥聊一下。 一 SecurityFilterChain 首先大夥都知道Spring Security 裏邊的一堆功能都是通過 Filter 來實現的無論是認證、RememberMe Login、會話管