为了账号安全,请及时绑定邮箱和手机立即绑定
慕课网数字资源数据库体验端
Spring入门篇_学习笔记_慕课网
为了账号安全,请及时绑定邮箱和手机立即绑定

Spring入门篇

moocer JAVA开发工程师
难度中级
时长 7小时 0分
  • <!-- this is the object that will be proxied by Spring's AOP infastructure --> <bean id="fooService" class="x.y.service.DefaultFooService"/> <!-- this is the actual advice itself --> <bean id="profiler" class="x.y.SimpleProfiler"/> <aop:config> <aop:aspect ref="profiler"> <aop:pointcut id="theExecutionOfSomeFooServiceMethod"expression="execution(* x.y.service.FooService.getFoo(String,int)) and args(name,age)"/> <aop:around pointcut-ref="theExecutionOfSomeFooServiceMethod" method="profile"/> </aop:aspect> </aop:config>
    查看全部
  • Advice parameters public interface FooService{ Foo getFoo(String fooName,int age); } public class DefaultFooService implements FooService{ public Foo getFoo(String name,int age){ return new Foo(name,age); } } public class SimpleProfiler{ public Object profile(ProceedingJoinPoint call,String name,int age) throws Throwable{ StopWatch clock=new StopWatch("Profiling for"+name+"and"+age+""); try{ clock.start(call.toShortString()); return call.proceed(); }finally{ clock.stop(); System.out.println(clock.prettyPrint()); } } }
    查看全部
  • <aop:config> <aop:aspect id="myAspect" ref="aBean"> <aop:pointcut id="businessService" expression="execution(* com.xyz.myapp.service..(..))"/> ... </aop:aspect> </aop:config>
    查看全部
  • <aop:config> <aop:pointcut id="businessService" expression="execution(* com.xyz.myapp.service..(..))"/> </aop:config> ********************************************** <aop:config> <aop:pointcut id="businessService" expression="com.xyz.myapp.SystemArchitecture.businessService()"/> </aop:config>
    查看全部
  • bean的作用域 Bean常用配置项 Id:整个IOC容器中bean的唯一标识。 Class:具体要实例化的类。 Scope:范围、作用域。 Constructor arguments:构造参数(设置构造注入的时候用到)。 Properties:属性(设置Set设值注入的时候用到)。 Autowiring mode:自动装配模式。 Lazy-initialization mode:懒加载模式。 Initialization/destruction method:初始化、销毁的方法。
    查看全部
  • 1.target(com.xyz.service.AccountService)(only in Spring AOP)------target用于匹配当前目标对象类型的执行方法 2.args(java.io.Serializable)(only in Spring AOP)------args 用于匹配当前执行的方法传入的参数为指定类型的执行方法 3.@target(org.springframework.transaction.annotation.Transactional)(only in Spring AOP) 4.@within(org.springframework.transaction.annotation.Transactional)(only in Spring AOP) 5.@annotation(org.springframework.transaction.annotation.Transactional)(only in Spring AOP) 6.@args(com.xyz.security.Classified)(only in Spring AOP) 7.bean(tradeService)(only in Spring AOP) 8.bean(*Service)(only in Spring AOP)
    查看全部
  • 环绕控制(就是说在执行的前后都可以添加一个动作): 简单理解就是:切入点“moocPiontcut”:当执行。。Biz下的所有方法时,调用bean(截面)“moocAspect”里的方法。然后例子中的before、after-returning、after-throwing、after以及第一个around环绕方法都一样。然后这几个方法的先后顺序(控制台输出)就如上所示。 第二个around方法里重新定义了一个切入点,当执行确切的某个方法的时候调用,当然因为这些切入点都在切面“moocAspectAOP”里面,它们都ref到了bean“moocAspect”里的对应方法。 *around方法里必有一个ProceedingJoinPoint参数并且返回值为Object
    查看全部
  • execution用于匹配方法执行的连接点 1.execution(public**(..))------切入点为执行所有public方法时 2.execution(* set*(..))------切入点为执行所有set开始的方法时 3.execution(* com.xyz.service.AccountService.*(..))------切入点为执行AccountService类中的所有方法时 4.execution(* com.xyz.service..(..))------切入点为执行com.xyz.service包下的所有方法时 5.execution(* com.xyz.service...(..))------切入点为执行com.xyz.service包及其子包下的所有方法时 6.within(com.xyz.service.*)(only in Spring AOP) 7.within(com.xyz.service..*)(only in Spring AOP) ------within用于匹配指定类型内的方法执行 8.this(com.xyz.service.AccountService)(only in Spring AOP) ------this用于匹配当前AOP代理对象类型的执行方法
    查看全部
  • Schema --based AOP Spring所有的切面和通知器都必须放在一个<aop:config>内(可以配置包含多个<aop:config>元素),每一个<aop:config>可以包含pointcut,advisor和aspect元素。 (他们必须按照这个顺序进行相应声明)
    查看全部
    0 采集 收起 来源:配置切面aspect

    2018-03-22

  • Spring的AOP实现 1.纯java实现,无需特殊的编译过程,不需要控制类加载器层次 2.目前只支持方法执行连接点(通知Spring Bean的方法执行) 3.不是为了提供最完整的AOP实现,而是侧重于提供一种AOP实现和Spring IoC容器之间的整合,用于帮助解决企业应用中的常见问题 4.Spring AOP不会与AspectJ竞争,从而提供综合全面的Aop解决方案
    查看全部
  • aop相关概念
    查看全部
  • @bean默认是单例的
    查看全部
  • 单元测试
    查看全部
    0 采集 收起 来源:IOC及Bean容器

    2017-02-28

  • classpath扫描与组件管理 1、从spring3.0开始,spring javaConfig项目提供了很多特性,包括使用Java而不是xml定义bean,比如@configuration,@bean,@import,@dependson。2、@Component是一个通用注解,可以用于任何bean。3、@repository,@service,@Controller是更有针对性的注解。 ——@Repository通常用于注解dao类型,即持久层。——@service通常用于注解service类,即服务层。——@controller通常用于controller类,即控制层(MVC)。
    查看全部
  • resources: 1、是spring针对于资源文件的同意入口。 2、Resources:1、URLResource:URL对应的资源,根据一个URL地址即可构建。2、ClassPathResource:获取类路径下的资源文件。3、FileSystemResource:获取文件系统里面的资源文件。4、ServletContextResource:ServletContext封装的资源,用于访问ServletContext环境下的资源。5、InputStrameResource:针对于输入流封装的资源。6、ByteArrayResource:针对字节组封装的资源。
    查看全部

举报

0/150
提交
取消
课程须知
Java的高级课程,适合对Java基础知识应用自如,并熟悉MVC架构的小伙伴们。如果想成为一名Java工程师,这门课程是一定要学哒。
老师告诉你能学到什么?
掌握依赖注入、IOC和AOP的概念,并能进行简单应用。
友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!