Merge branch 'main' of https://bdgit.educoder.net/ph3fvx2sj/FamilyFinancialManagementSystem25-12B
commit
de159c6bfd
@ -0,0 +1,20 @@
|
||||
# 编译输出目录
|
||||
out/
|
||||
target/
|
||||
build/
|
||||
*.class
|
||||
|
||||
# IDE 配置
|
||||
.idea/
|
||||
*.iml
|
||||
.vscode/
|
||||
|
||||
# 临时文件
|
||||
*.log
|
||||
*.tmp
|
||||
*.swp
|
||||
*~
|
||||
|
||||
# 操作系统文件
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
@ -0,0 +1,54 @@
|
||||
<?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"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/aop
|
||||
http://www.springframework.org/schema/aop/spring-aop.xsd">
|
||||
|
||||
<!-- 组长的User实体 -->
|
||||
<bean id="user" class="com.ssm.aop.xml.User">
|
||||
<property name="id" value="1"/>
|
||||
<property name="username" value="zhangsan"/>
|
||||
<property name="userpass" value="123456"/>
|
||||
<property name="truename" value="张三"/>
|
||||
<property name="phone" value="13800130000"/>
|
||||
<property name="createTime" value="2024-01-01"/>
|
||||
</bean>
|
||||
|
||||
<!-- 于杉杉的StockAccount实体 -->
|
||||
<bean id="stockAccount" class="com.ssm.aop.xml.StockAccount">
|
||||
<property name="id" value="3001"/>
|
||||
<property name="userId" value="1"/>
|
||||
<property name="accountName" value="张三的A股账户"/>
|
||||
<property name="broker" value="东方财富证券"/>
|
||||
<property name="balance" value="100000.00"/>
|
||||
<property name="createDate" value="2023-06-18"/>
|
||||
</bean>
|
||||
|
||||
<!-- 籍美翎的StockAccount实体 -->
|
||||
<bean id="income" class="com.ssm.aop.xml.Income">
|
||||
<property name="id" value="1001"/>
|
||||
<property name="userId" value="1"/>
|
||||
<property name="type" value="工资"/>
|
||||
<property name="money" value="5000"/>
|
||||
<property name="incomeTime" value="2024-04-01"/>
|
||||
</bean>
|
||||
|
||||
<!-- AOP日志 -->
|
||||
<bean id="log" class="com.ssm.aop.xml.Log"/>
|
||||
|
||||
<!-- AOP配置 -->
|
||||
<aop:config>
|
||||
<aop:aspect ref="log">
|
||||
<aop:before method="before"
|
||||
pointcut="execution(* com.ssm.aop.xml..printInfo(..))"/>
|
||||
</aop:aspect>
|
||||
</aop:config>
|
||||
|
||||
|
||||
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,19 @@
|
||||
package com.ssm.aop.xml;
|
||||
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import java.util.Date;
|
||||
|
||||
public class Log {
|
||||
public void before(JoinPoint jp) {
|
||||
System.out.println("==================================");
|
||||
System.out.println("【前置通知】开始执行方法:" + jp.getSignature().getName());
|
||||
System.out.println("【前置通知】执行时间:" + new Date());
|
||||
System.out.println("==================================");
|
||||
}
|
||||
public void before(JoinPoint jp, String param) {
|
||||
System.out.println("==================================");
|
||||
System.out.println("【前置通知】开始执行方法:" + jp.getSignature().getName());
|
||||
System.out.println("【前置通知】执行时间:" + new Date());
|
||||
System.out.println("==================================");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.ssm.aop.xml;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
public class TestAop {
|
||||
public static void main(String[] args) {
|
||||
ApplicationContext ac = new ClassPathXmlApplicationContext("bean-aop.xml");
|
||||
User user = (User) ac.getBean("user");
|
||||
user.printInfo();
|
||||
StockAccount stockAccount = (StockAccount) ac.getBean("stockAccount");
|
||||
stockAccount.printInfo();
|
||||
Income income = (Income)ac.getBean("income");
|
||||
income.printInfo();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Loading…
Reference in new issue