声明切面类
@Aspect(切面): 通常是一个类,里面可以定义切入点和通知
使用注解的方式代替这些配置
Stpe1:Service层
public interface VideoService {
int save(Video video);
Video findById(int id);
}
Step2:ServiceImpl实现类
@Service("videoService")
public class VideoServiceImpl implements VideoService {
@Autowired
private CustomConfig customConfig;
public int save(Video video) {
System.out.println(customConfig.getHost());
System.out.println("保存video");
return 1;
}
public Video findById(int id) {
System.out.println("根据id查询视频信息");
return new Video();
}
}
Step3:配置切点通知
@Configurati