当前位置: 首页 > news >正文

网站建设系统设计报告卖钢材做哪个宣传网站

网站建设系统设计报告,卖钢材做哪个宣传网站,广州手机网站设计,企业网站大图B站 【尚硅谷新版SSM框架全套视频教程#xff0c;Spring6SpringBoot3最新SSM企业级开发】https://www.bilibili.com/video/BV1AP411s7D7?p47vd_source726decf3eb63273901caae35ad437124 AOP即面向切面编程,通过使用一定的技术将非核心方法抽离出来,放入统一的类中进行… B站 【尚硅谷新版SSM框架全套视频教程Spring6SpringBoot3最新SSM企业级开发】https://www.bilibili.com/video/BV1AP411s7D7?p47vd_source726decf3eb63273901caae35ad437124 AOP即面向切面编程,通过使用一定的技术将非核心方法抽离出来,放入统一的类中进行管理,在目标方法(核心方法)需要使用对应的非核心方法时,再将非核心方法插入的核心方法中,最后形成一个整合类进行使用. 需要导入相应的依赖 dependencygroupIdorg.springframework/groupIdartifactIdspring-context/artifactIdversion5.3.25/version /dependency spring-context依赖中包含了spring-aop依赖 dependencygroupIdorg.springframework/groupIdartifactIdspring-aspects/artifactIdversion5.3.25/version /dependency 方式一:通过类的接口实现AOP操作 创建接口: Service public interface Colculer {int Plus(int a,int b);int subtract(int a,int b);int multiply(int a,int b);int divide(int a,int b); } 创建实现类: Component public class Colcu implements Colculer {Overridepublic int Plus(int a,int b) {int resultab;return result;}Overridepublic int subtract(int a, int b) {return a-b;}Overridepublic int multiply(int a, int b) {return a*b;}Overridepublic int divide(int a, int b) {return a/b;} }创建配置类:(注意配置类中需要声明开启对adpect的注解) //表示我这个是一个配置类 Configuration //指定我要扫描的位置 ComponentScan({Com.su}) //开启对aspect的注解 EnableAspectJAutoProxy public class ConfigClass { }创建增强类:(aspect注解表示他是一个切面) Component Aspect public class AopLog {//前置通知Before(execution(* Com.su.*.*(..)))public void log(){System.out.println(输出了);} }在测试类中调用被增强后的类中的方法: //SpringJUnitConfig(value ConfigClass.class) ContextConfiguration(classes {ConfigClass.class}) RunWith(SpringJUnit4ClassRunner.class) public class MyTest {Autowiredprivate Colculer colculer;Testpublic void test01(){int result colculer.Plus(2, 6);System.out.println(abresult);} } 调用方法后发现被调用的方法被增强了结果如下: 九月 08, 2023 10:39:33 上午 org.springframework.test.context.support.AbstractTestContextBootstrapper getDefaultTestExecutionListenerClassNames 信息: Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener] 九月 08, 2023 10:39:33 上午 org.springframework.test.context.support.AbstractTestContextBootstrapper getTestExecutionListeners 信息: Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener3abbfa04, org.springframework.test.context.event.ApplicationEventsTestExecutionListener57fffcd7, org.springframework.test.context.support.DependencyInjectionTestExecutionListener31ef45e3, org.springframework.test.context.support.DirtiesContextTestExecutionListener598067a5, org.springframework.test.context.event.EventPublishingTestExecutionListener3c0ecd4b] 输出了 ab8AOP增强类的解释: 切面:可以理解为创建的这个aspect注解类就是切面 切点:被选中的方法即为切点execution(方法的全路径) 增强:方法中的具体代码 拓展1: 注解的形式开启AOP ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xmlns:aophttp://www.springframework.org/schema/aopxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd!-- 注解的形式开启AOP--aop:aspectj-autoproxy/ /beans 配置类: //开启对aspect的注解 EnableAspectJAutoProxy 拓展2: 拓展3: 在测试方法中将声明接口改为声明接口实现类 无法实现对应代理类 原因:在进行AOP动态代理时,底层会根据类的类型选择对应的代理模式,这个类中有对应的接口,所以代理时会选用JDK动态代理的形式,而JDK代理会根据这个类对应的接口实现一个代理类. 即代理对象和目标对象是兄弟关系(不很懂!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) 来自弹幕的解释(相当于bc都实现了a接口但bc不是子父类的关系无法用多态。但是如果没实现接口代理对象和被增强对象是父子类关系是可以用多态来接受的) 通过上面的测试可得:即在IOC容器中真正存储的都是代理对象,不是目标对象 拓展4:如何在增强类中获取我们的目标信息(只需要在方法中添加一个形参JoinPoint) 注意是JoinPoint不是JointPoint 1.获取方法所属的类的信息 2.获取方法的名称 3.获取参数的列表 Component Aspect public class AopLog {//前置通知Before(execution(* Com.su.*.*(..)))public void log(JoinPoint joinPoint){//获取方法所属的类的信息String simpleName joinPoint.getTarget().getClass().getSimpleName();//获取方法的名称String name joinPoint.getSignature().getName();//获取参数列表Object[] args joinPoint.getArgs();System.out.println(simpleName是simpleNamenamenameargs是args);System.out.println(输出了);System.out.println(simpleName);} }
http://www.zqtcl.cn/news/342159/

相关文章:

  • 网站文章怎么做分享qq做网站傻瓜
  • 自媒体专用网站免费产品推广文案100字
  • 阜阳专业网站建设上海南桥网站建设
  • 网站默认图片阳春做网站
  • 怎么自己做网站排名福州朝阳房产网站建设
  • 贵州建网站红动中国免费素材网
  • 公益网站建设婚庆网站开发的意义
  • 徐州网站建设案例南京设计网站
  • 培训网站欣赏网站开发进度管理表
  • 网站开发工程师考试平面设计实例网站
  • ftp更换网站备案密码如何登录添加网站
  • 钢球 东莞网站建设做网站用vue吗
  • 青岛网站建设制作公司制作视频软件哪个免费
  • 用flash做的网站欣赏承德住房和城乡建设局网站关闭了
  • 做网站引流的最佳方法施工企业高级工程师土建答辩
  • 成都优创智汇网站建设旅游网站网页设计代码
  • 郑州冬青街 网站建设网站seo技巧
  • 网站定制公司推荐外包公司怎么样
  • 深圳做网站要网站制作能在家做吗
  • 设计国外网站深圳外贸网站推广
  • wordpress首页文章分类展示站长工具seo综合查询引流
  • 整网站代码 带数据 免费 下载株洲网站的建设
  • 邢台学校网站建设价格个人博客首页
  • php做网站优势wordpress导航图片尺寸
  • 西安商城网站建设咪豆com域名表示的是什么机构
  • 网站如何申请微信支付接口织梦中英文网站源码
  • 礼县住房和城乡建设局网站化妆品的网站设计方案
  • 做外汇网站代理公关团队
  • wordpress登录页面创建seo网站平台
  • 兰州seo整站优化服务商企业网站seo优化方案