2.編寫測試類:
package com.test;
import org.springframework.stereotype.controller;
import org.springframework.web.bind.annotation.responsebody;
/*** @author tgy:
* @version 1.0
* createtime:2023年12月16日 下午3:48:45
* 類說明:
*/@controller
public class test_aop
}
3.編寫切面類:
package com.test;
import org.aspectj.lang.annotation.after;
import org.aspectj.lang.annotation.aspect;
import org.aspectj.lang.annotation.before;
import org.aspectj.lang.annotation.pointcut;
import org.springframework.stereotype.component;
/*** @author tgy:
* @version 1.0
* createtime:2023年12月16日 下午3:52:06
* 類說明:
*/@aspect
@component
public class deal_aop //這時的pointcut()即代表乙個切面
@before("pointcut()")
public void before()
@after("pointcut()")
public void after()
}
4.進行結果:
進行專案訪問:http://localhost:8080/project/testaop/get
控制台結果:
小白設計模式入門(1) 單例模式
什麼是單例模式?單例可以理解為乙個類只有乙個例項,因此單例模式就是為了保證這個類只會有乙個例項而總結的一種方法。它在什麼情況下使用的?從單例模式的定義中我們可以看出 單例模式的使用自然是當我們的系統中某個物件只需要乙個例項的情況,例如 作業系統中只能有乙個任務管理器,操作檔案時,同一時間內只允許乙個...
docker 小白入門
第一步開啟伺服器 第二部重開cmd 檢查docker的版本,這樣可以用來確認docker服務在執行並可通過客戶端鏈結。docker version 學會使用命令列的工具來檢索名字叫做tutorial的映象。命令列的格式為 docker search 映象名字 docker search tutori...
小白入門Mybatis
mybatis 資料持久化 持久化是程式資料在瞬時狀態和持久狀態間的轉換過程 orm 編寫程式的時候,以物件導向的方式處理資料。儲存資料的時候卻以關係型資料庫的方式儲存資料 orm提供 在持久化物件上執行基本的增 刪 改 查操作 對持久化物件提供一種查詢語言或者api 物件關係對映工具 提供與事務物...