摘要:
spring基于注解配置aop案例 1、导入jar包 基于maven项目 <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.8.14</version> </de 阅读全文
摘要:
spring中环绕通知的用法 环绕通知: 它是spring框架为我们提供的一种可以在代码中手动控制增强部分什么时候执行的方式。 问题: 当我们配置了环绕通知之后,增强的代码执行了,业务核心方法没有执行。 分析: 通过动态代理我们知道在invoke方法中,有明确调用业务核心方法:method.invo 阅读全文
摘要:
spring导入properties配置文件 将外部属性文件的数据配置到bean的配置文件,依赖于context标签下的property-placeholder标签 1、准备properties文件 url=jdbc:mysql://localhost:3306/hibernate_db usern 阅读全文
摘要:
spring中切入点表达式说明 execution: 匹配方法的执行(常用) execution(表达式) 表达式语法:execution([修饰符] 返回值类型 包名.类名.方法名(参数)) 写法说明: 全匹配方式: public void com.itheima.service.impl.Cus 阅读全文
摘要:
spring基于xml配置aop入门案例 1、导入jar包 基于maven项目 <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.8.14</version> < 阅读全文
摘要:
spring中FactoryBean类的用法 1、简介 工厂bean,它是作用主要就是创建bean对象 2、如何使用 2.1、编写实体类 package com.yl.bean; public class Car { private String brand; private Integer pri 阅读全文
摘要:
spring基于xml导入配置文件 在原先的bean的xml配置文件导入另外的bean xml配置文件,都受同一个IOC容器的管理及配置 用法 <!--导入bean1.xml文件的内容--> <import resource="bean1.xml" /> 阅读全文
摘要:
spring中bean的继承和依赖关系 1、bean之间的继承 将公共的配置写到父bean,子bean直接继承即可使用 举例 定义一个父bean <!--实现bean之间的继承关系--> <bean id="parentCar" class="com.gec.bean.Car" > <propert 阅读全文
摘要:
spring整合junit 首先准备好spring项目,新建spring项目可以参考以下资料 spring基于xml配置入门案例 spring注解入门案例 spring纯注解案例 这里就不再阐述怎么新建spring项目了,准备好spring项目环境之后,就可以开始spring整合junit了 1、导 阅读全文
摘要:
spring新注解说明 @Configuration、@ComponentScan在纯注解案例中已经说明,就不再阐述;这里主要讲一下@PropertySource、@Import、@Bean 1、@PropertySource 作用:用于加载.properties文件中的配置。例如我们配置数据源时, 阅读全文
摘要:
spring纯注解案例 我们发现,之所以我们现在离不开xml配置文件,是因为我们有一句很关键的配置: <!-- 告知spring框架在,读取配置文件,创建容器时,扫描注解,依据注解创建对象,并存入容器中 --> <context:component-scan base-package=**"com. 阅读全文
摘要:
spring常用注解的使用 1、用于创建对象 相当于: 1.1、@Component 作用:把资源让spring来管理,相当于在xml中配置一个bean。 属性 value:指定bean的id;如果不指定value属性,默认bean的id是当前类的类名,首字母小写。 1.2、@Controller、 阅读全文
摘要:
spring注解入门案例 基于maven项目 1、准备jar包 <!-- https://mvnrepository.com/artifact/org.springframework/spring-context --> <dependency> <groupId>org.springframewo 阅读全文