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

中小学教师兼职做网站企业主页图片

中小学教师兼职做网站,企业主页图片,网站共享备案,关键词排名优化公司地址在某些类中, 什么时机, 做什么事情 切入点(point-cut): 在某些类中(Class?[] itfc new Class?[] { IStudentService.class }) 通知: 什么时机, 做什么事情(InvocationHandler的invoke方法) 切面: 切入点 通知 织入(weaver): Proxy.newProxyInstance: 把切入…在某些类中, 什么时机, 做什么事情 切入点(point-cut): 在某些类中(Class?[] itfc new Class?[] { IStudentService.class }) 通知: 什么时机, 做什么事情(InvocationHandler的invoke方法) 切面: 切入点 通知 织入(weaver): Proxy.newProxyInstance: 把切入点和通知施加到具体的业务逻辑上的过程 XML配置AOP步骤: 1,准备了一个实现接口的bean, 还有一个事务的碎片化方法的类; 2,把这两个类配置到Spring容器中; 3,配置springAOP  1)引入aop命名空间;  2)配置AOP,格式如下  aop:config      aop:point-cut expression  idsample /      aop:aspect ref           aop:before method pointcut-refsample           aop:after-returning method pointcut-refsample           aop:after-throwing method pointcut-refsample      /aop:aspect  /aop:config   1] aop:config: AOP配置   2] aop:point-cut: AOP切入点   3] aop:aspect: AOP切面配置   4] aop:* 都是一个AOP切面  4,在接口文件中配置一个业务逻辑对象的接口,DI注入,并在test方法中直接调用该接口的具体业务逻辑 //接口: package com.xk.spring.kp04_aop.aop.s01_xml;public interface IStudentService {public void save(Student stu);public void update(Student stu); } //Dao 实现类(service) 实现业务逻辑 package com.xk.spring.kp04_aop.aop.s01_xml;public class StudentServiceImpl implements IStudentService {Overridepublic void save(Student stu) {System.out.println(调用Dao的save方法....);}Overridepublic void update(Student stu) {System.out.println(调用Dao的update方法...);SuppressWarnings(unused)int i 10/0;} } //事物管理:将代码中的污染源抽出一个类,专门处理事物 package com.xk.spring.kp04_aop.aop.s01_xml;public class TransactionManager {/*** 事物开始*/public void begin(){System.out.println(TransactionManager.begin());}/*** 事物提交*/public void commit(){System.out.println(TransactionManager.commit());}/*** 事物回滚*/public void rollback(Throwable e){System.out.println(TransactionManager.rollback());System.out.println(rollback());}/*** 事物结束*/public void finished(){System.out.println(TransactionManager.close());} } //Bean //将bean注入就是指将数据注入Spring package com.xk.spring.kp04_aop.aop.s01_xml;public class Student {private String name;private Integer age;public Student() {}public Student(String name, Integer age) {this.name name;this.age age;}public String getName() {return name;}public void setName(String name) {this.name name;}public Integer getAge() {return age;}public void setAge(Integer age) {this.age age;}Overridepublic String toString() {return Student [name name , age age ];} }//测试类 package com.xk.spring.kp04_aop.aop.s01_xml;import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;RunWith(SpringJUnit4ClassRunner.class) ContextConfiguration public class AOPXMLTest {AutowiredIStudentService seriver;Testpublic void testAOPXML() throws Exception {seriver.save(new Student(张三, 18));seriver.update(new Student(张4, 18));} } !-- xml配置aop -- ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:contexthttp://www.springframework.org/schema/contextxmlns:aophttp://www.springframework.org/schema/aop xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop.xsdbean idservice classcom.xk.spring.kp04_aop.aop.s01_xml.StudentServiceImpl /bean idmanager classcom.xk.spring.kp04_aop.aop.s01_xml.TransactionManager /aop:config!-- 需要导入两个依赖包 com.springsource.org.aopalliance-1.0.0.jar和com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar --aop:pointcutexpressionexecution(* com.xk.spring.kp04_aop.aop.s01_xml.*Service.*(..))idstuService /aop:aspect refmanageraop:before methodbegin pointcut-refstuService /!-- 回滚:在回滚的时候 throwing是要在TransactionManager类中配置的 参数(throwable e) --aop:after-throwing methodrollbackpointcut-refstuService throwinge //aop:aspect/aop:config /beans!-- 错误:Pointcut is not well-formed: expecting name pattern at character position 配置aop报错原因是配置切点表达式的时候报错了 星号后面没有加空格 aop:config aop:pointcut idtransactionPointcut expressionexecution(* project.mybatis.service.*.*(..)) / aop:advisor pointcut-reftransactionPointcut advice-refomsMTransactionAdvice / /aop:config 其中切入点表达式的使用规则 1、execution(): 表达式主体。 2、第一个*号表示返回类型*号表示所有的类型。 3、包名表示需要拦截的包名后面的两个句点表示当前包和当前包的所有子包com.sample.service.impl包、子孙包下所有类的方法。 4、第二个*号表示类名*号表示所有的类。 5、*(..):最后这个星号表示方法名*号表示所有的方法后面括弧里面表示方法的参数两个句点表示任何参数。 --  转载于:https://www.cnblogs.com/huike/p/6636731.html
http://www.zqtcl.cn/news/577386/

相关文章:

  • 制作网站的步骤和方法做物流的网站有哪些功能
  • vs做网站图片明明在文件夹里却找不到中国建筑网官网找客户信息
  • WordPress仿站培训黑龙江新闻夜航
  • 如何利用开源代码做网站济南做网站互联网公司有哪些
  • 生意网app下载官网郑州做网站优化公
  • wordpress网站更换域名wordpress 小工具定制
  • 上海做机床的公司网站设计网站怎样做色卡
  • 一个网站怎么绑定很多个域名做网站后台应该谁来做
  • 跑纸活做网站加大门户网站安全制度建设
  • 多商户开源商城seo对网店的作用有哪些
  • 提供微信网站建设福州seo建站
  • 泉州市住房与城乡建设网站潍坊网站建设方案外包
  • 网络文化经营许可证怎么申请免费seo提交工具
  • 网站建设 需求分析报告手机网站微信网站开发
  • 做司法考试题目的网站建站中企动力
  • 做360网站优化ppt模板免费下载千图网
  • 网站域名哪些后缀更好项目推广平台有哪些
  • 做游戏特效的网站网站开发中安全性的防范
  • 阿里云网站建设好用吗齐诺网站建设
  • 中小企业网站建设行情嘉兴公司的网站设计
  • 做服装有哪些好的网站台州网站建设多少钱
  • 任县网站建设公司北京网站开发网站开发公司
  • 重庆seo网站策划网站的tdk指的是什么
  • 自做刷赞网站山东东成建设咨询有限公司网站
  • 泉州网站制作推广网站建设一年多少
  • 超大型网站建设公司网站打开显示建设中
  • 惠东县网站建设建设方案
  • 怎么把做的网站发布长春建网站
  • 织梦网站手机端郑州网站制作公司名单
  • 如何建设网站安全网站桥页也叫