技术标签: spring AOP java # Spring学习 SSM框架 IOC
个人主页: 不断前进的皮卡丘
博客描述: 梦想也许遥不可及,但重要的是追梦的过程,用博客记录自己的成长,记录自己一步一步向上攀登的印记
网站推荐:千里之行,始于足下。每天坚持刷题,巩固所学知识,也为将来找工作,面试做好准备----- 刷题神器
文章是看楠哥的视频写的笔记
这篇博客内容把Spring的基本知识点都讲到了,篇幅比较长,大家可以用于复习,也可以在学习相关知识点的时候,来看看对应内容。对于一些难点,IOC,AOP等,我通过流程图,代码,文字结合来进行讲解,可以更好的理解
传统开发中,需要调用对象的时候,需要调用者手动来创建被调用者的实例,即对象是由调用者new出来的
但是在Spring框架中,创建对象的工作不再由调用者来完成,而是交给IOC容器来创建,再推送给调用者,整个流程完成反转,所以是控制反转
就比如说假设买东西,以前我们需要自己去超市买东西,但是现在我们可以不用自己去超市,我们只要把购物袋放在家门口,IOC就会自己去把我们想要的东西买回来,然后放在袋子里面,我们打开袋子拿起来用就可以了
IOC的特点是解耦合。
比如说A需要用到B,传统的开发,我们要直接创建B的实例,但是在Spring中,IOC这个容器会创建B的实例,然后把这个B注入到A
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>springioc</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.18</version>
</dependency>
</dependencies>
</project>
public class Student {
private long id;
private String name;
private int age;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public String toString() {
return "Student{" +
"id=" + id +
", name='" + name + '\'' +
", age=" + age +
'}';
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="stu" class="com.zyh.pojo.Student"></bean>
</beans>
Student stu =new Student();
stu .setAge(25);
stu.setId(1001);
stu.setName("张三");
System.out.println(stu);
bean
标签来创建对象//读取配置文件
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
Student stu = applicationContext.getBean("stu", Student.class);
System.out.println(stu);
bean
标签来完成对象的管理id
:对象名class
:对象的模板类(所有交给IOC容器来管理的类必须要有无参构造函数,因为Spring底层是通过反射机制来创建对象,调用的是无参构造)property
标签完成赋值
name
:成员变量名value
:成员变量值(基本数据类型,String可以直接赋值,如果是其他引用类型不可以通过value赋值)ref
:把IOC中的另一个bean赋给当前成员变量(DI)无参构造函数(需要提供对应的set方法)
有参构造函数
<bean id="stu1" class="com.zyh.pojo.Student">
<constructor-arg name="id" value="1"> </constructor-arg>
<constructor-arg name="name" value="李四"></constructor-arg>
</bean>
<bean id="stu1" class="com.zyh.pojo.Student">
<constructor-arg index=0 value="1"> </constructor-arg>
<constructor-arg index=1 value="李四"></constructor-arg>
</bean>
Student stu = (Student)applicationContext.getBean("stu");
Student stu = applicationContext.getBean( Student.class);
public class Classes {
private Integer id;
private String name;
还有对应的get,set方法
}
public class Student {
private long id;
private String name;
private int age;
private Classes classes;
public Student(){
System.out.println("使用无参构造创建对象");
}
public Student(long id,String name){
this.id = id;
this.name = name;
}
public Classes getClasses() {
return classes;
}
public void setClasses(Classes classes) {
this.classes = classes;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public String toString() {
return "Student{" +
"id=" + id +
", name='" + name + '\'' +
", age=" + age +
", classes=" + classes +
'}';
}
}
applicationContext-di.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="classes" class="com.zyh.pojo.Classes">
<property name="name" value="1班"></property>
<property name="id" value="1"></property>
</bean>
<bean id="student" class="com.zyh.pojo.Student">
<property name="id" value="1001"></property>
<property name="name" value="张三"></property>
<property name="age" value="22"></property>
<property name="classes" ref="classes"></property>
</bean>
</beans>
bean之间的级联需要使用ref属性,而不能用value属性,否则会抛出类型转换异常
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="classes" class="com.zyh.pojo.Classes">
<property name="name" value="1班"></property>
<property name="id" value="1"></property>
<property name="studentList">
<list>
<ref bean="student"></ref>
<ref bean="student2"></ref>
</list>
</property>
</bean>
<bean id="student" class="com.zyh.pojo.Student">
<property name="id" value="100"></property>
<property name="name" value="张三"></property>
<property name="age" value="22"></property>
<property name="classes" ref="classes"></property>
</bean>
<bean id="student2" class="com.zyh.pojo.Student">
<property name="id" value="200"></property>
<property name="age" value="18"></property>
<property name="name" value="李四"></property>
<property name="classes" ref="classes"></property>
</bean>
</beans>
如果把学生装到班级里面,又把班级装到学生里面,就导致无限递归循环装配,最终栈溢出
bean是根据scope来生成的,表示bean的作用域,scope有4种类型
singleton,单例,表示通过Spring容器获取的对象是唯一的,是默认值
prototype,原型,表示通过Spring容器获取的对象是不同的
<bean id="user" class="com.zyh.pojo.User" scope="prototype">
<property name="id" value="1"></property>
<property name="name" value="张三"></property>
</bean>
Spring中的继承不同于Java中的继承
Java中的继承是针对于类的
Spring中的继承是针对于对象(bean)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="user1" class="com.zyh.pojo.User" >
<property name="id" value="1"></property>
<property name="name" value="张三"></property>
</bean>
<bean id="user2" class="com.zyh.pojo.User" parent="user1"></bean>
</beans>
jdbc.properties
user=root
password=root
url=jdbc:mysql://localhost:3306/spring
driverName=com.mysql.cj.jdbc.Driver
spring-properties.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
<!--导入外部资源 -->
<context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>
<bean id="dataSource" class="com.zyh.pojo.DataSource">
<property name="username" value="${user}"></property>
<property name="password" value="${password}"></property>
<property name="url" value="${url}"></property>
<property name="driveName" value="${driverName}"></property>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="stu" class="com.zyh.pojo.Student" p:id="1" p:age="10" p:name="张三" p:classes-ref="classes"></bean>
<bean id="classes" class="com.zyh.pojo.Classes" p:name="一班" p:id="1"></bean>
</beans>
IOC通过工厂模式创建bean有两种方式:
public class Car {
private Integer num;
private String brand;
public Car() {
}
public Car(Integer num, String brand) {
this.num = num;
this.brand = brand;
}
public Integer getNum() {
return num;
}
public void setNum(Integer num) {
this.num = num;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
@Override
public String toString() {
return "Car{" +
"num=" + num +
", brand='" + brand + '\'' +
'}';
}
}
public class StaticCarFactory {
private static Map<Integer, Car> carMap;
static {
carMap = new HashMap<>();
carMap.put(1, new Car(1, "奥迪"));
carMap.put(2, new Car(2,"奥拓"));
}
/**
* 写一个方法,从map集合取数据
*/
public static Car getCar(Integer num ){
return carMap.get(num);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="car" class="com.zyh.factory.StaticCarFactory" factory-method="getCar">
<constructor-arg name="num" value="1"></constructor-arg>
</bean>
</beans>
public class InstanceCarFactory {
private Map<Integer, Car> carMap;
public InstanceCarFactory() {
carMap = new HashMap<>();
carMap.put(1, new Car(1, "奥迪"));
carMap.put(2, new Car(2, "奥拓"));
}
public Car getCar(Integer num){
return carMap.get(num);
}
}
<!-- 实例工厂类-->
<bean id="instanceCarFactory" class="com.zyh.factory.InstanceCarFactory"></bean>
<!-- 通过实例工厂获取Car-->
<bean id="car1" factory-bean="instanceCarFactory" factory-method="getCar">
<constructor-arg value="2"></constructor-arg>
</bean>
区别:
byName的操作如下:
public class Person {
private Integer id;
private String name;
private Car car;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Car getCar() {
return car;
}
public void setCar(Car car) {
this.car = car;
}
@Override
public String toString() {
return "Person{" +
"id=" + id +
", name='" + name + '\'' +
", car=" + car +
'}';
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="car2" class="com.zyh.pojo.Car">
<constructor-arg name="num" value="1"></constructor-arg>
<constructor-arg name="brand" value="奥迪"></constructor-arg>
</bean>
<bean id="car" class="com.zyh.pojo.Classes"></bean>
<bean id="person" class="com.zyh.pojo.Person" autowire="byName" >
<property name="name" value="张三"></property>
<property name="id" value="2"></property>
</bean>
</beans>
注:如果bean的id有多个一致的,会报错,如Bean name 'car' is already used in this <beans> element
byType的操作如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="car2" class="com.zyh.pojo.Car">
<constructor-arg name="num" value="1"></constructor-arg>
<constructor-arg name="brand" value="奥迪"></constructor-arg>
</bean>
<bean id="car" class="com.zyh.pojo.Classes"></bean>
<bean id="person" class="com.zyh.pojo.Person" autowire="byType" >
<property name="name" value="张三"></property>
<property name="id" value="2"></property>
</bean>
</beans>
使用byType进行自动装配的时候,必须保证IOC中有且只有一个符合,如果有多个符合,则报下面的异常:
Spring IOC的作用是帮助开发者创建项目中所需要的bean,同时完成bean之间的依赖注入关系,DI
实现该功能有两种方式:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
<!-- 配置自动扫包-->
<context:component-scan base-package="com.zyh.pojo"></context:component-scan>
<!-- <bean id="repository" class="com.zyh.pojo.Repository"></bean>-->
</beans>
@Component(value="repository")
public class Repository {
private DataSource dataSource;
public DataSource getDataSource() {
return dataSource;
}
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public String toString() {
return "Repository{" +
"dataSource=" + dataSource +
'}';
}
}
DI
注解默认的beanid是类名以小写开头,我们可以通过value来设置
如果我们想要把datasource也注入进来需要怎么做呢?
首先我们要把DataSource先扫进来
@Component
public class Repository {
@Autowired
private DataSource dataSource;
public DataSource getDataSource() {
return dataSource;
}
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public String toString() {
return "Repository{" +
"dataSource=" + dataSource +
'}';
}
}
@Component
public class Repository {
@Autowired
@Qualifier(value = "datasource")
private DataSource dataSource;
public DataSource getDataSource() {
return dataSource;
}
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public String toString() {
return "Repository{" +
"dataSource=" + dataSource +
'}';
}
}
这表明把IOC中id为datasource的bean注入到repository中
实体类中普通的成员变量(String,包装类等),可以通过@Value注解来赋值
@Component
public class DataSource {
@Value("root")
private String username;
@Value("123456")
private String password;
@Value("jdbc:mysql://localhost:3306/spring")
private String url;
@Value("com.mysql.cj.jdbc.Driver")
private String driveName;
}
实际开发中我们会把程序分成三层:
通过一个例子来理解AOP。
public interface Cal {
public int add(int num1,int num2);
public int sub(int num1,int num2);
public int mul(int num1,int num2);
public int div(int num1,int num2);
}
public class CalImpl implements Cal {
@Override
public int add(int num1, int num2) {
int res = num1 + num2;
return res;
}
@Override
public int sub(int num1, int num2) {
int res = num1 - num2;
return res;
}
@Override
public int mul(int num1, int num2) {
int res = num1 * num2;
return res;
}
@Override
public int div(int num1, int num2) {
int res=num1/num2;
return res;
}
}
日志打印
对于计算器来说,加减乘除就是业务代码,日志打印就是非业务代码
AOP如何实现? 使用动态代理的方式来实现
代理首先要具备CalImpl的所有功能(实现同一个接口),并且在这个基础上,扩展出打印日志的功能
public class MyInvocationHandler implements InvocationHandler {
//委托对象
private Object object = null;
//返回代理对象
public Object bind(Object object) {
this.object = object;
return Proxy.newProxyInstance(object.getClass().getClassLoader(),
object.getClass().getInterfaces(),this);
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
//实现业务代码和非业务代码的解耦合
System.out.println(method.getName()+"方法的参数是:"+ Arrays.toString(args));
Object res = method.invoke(this.object, args);
System.out.println(method.getName()+"方法的结果是:"+res);
return res;
}
}
上述代码通过动态代理机制实现了业务代码和非业务代码的解耦合,这是Spring AOP的底层实现机制,真正使用 Spring AOP进行开发的时候,不需要这么复杂
Spring AOP的开发步骤
@Component
@Aspect
public class LoggerAspect {
@Before("execution(public int com.zyh.aop.impl.CalImpl.*(..))")
public void before(JoinPoint joinPoint) {
String name = joinPoint.getSignature().getName();
Object[] args = joinPoint.getArgs();
System.out.println(name + "方法的参数是:" + Arrays.toString(args));
}
@After("execution(* com.zyh.aop.impl.CalImpl.*(..))")
public void after(JoinPoint joinPoint){
String name = joinPoint.getSignature().getName();
System.out.println(name+"方法执行完毕");
}
@AfterReturning(value = "execution(* com.zyh.aop.impl.CalImpl.*(..))",returning = "rs")
public void afterReturning(JoinPoint joinPoint,Object rs){
String name = joinPoint.getSignature().getName();
System.out.println(name+"方法执行的结果是:"+rs);
}
@AfterThrowing(value = "execution(* com.zyh.aop.impl.CalImpl.*(..))",throwing = "ex")
public void afterThrowing(JoinPoint joinPoint,Exception ex){
String name = joinPoint.getSignature().getName();
System.out.println(name+"方法抛出异常"+ex);
}
}
@Component
public class CalcImpl implements Calc{
@Override
public int add(int a, int b) {
int result=a+b;
return result;
}
@Override
public int sub(int a, int b) {
int result=a-b;
return result;
}
@Override
public int mul(int a, int b) {
int result= a*b;
return result;
}
@Override
public int div(int a, int b) {
int result= a/b;
return result;
}
}
3.spring-aop.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 自动扫包-->
<context:component-scan base-package="com.zyh.aop"></context:component-scan>
<!-- 为委托对象自动生成代理对象-->
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
</beans>
4.测试
AOP的概念
文章浏览阅读488次。那些年,和我们一起成长的应届生们在云和恩墨,有这样一个专业化团队,他们深耕于数据技术服务一线,围绕客户数据系统全生命周期需求,提供端到端的软件产品、专业服务和解决方案,持续为客户创造价值,..._云和恩墨适合应届生吗
文章浏览阅读708次。为了让自己的数据类能够做到最大化的重用,就写个能够重用的PDO操作MySql的类:由于pdo可以连接现在流行的各种数据库,所以单独的写个配置类类来完成不同数据库DSN的配置:/** * 类标准说明 PDO连接数据库的配置类 * 类名: ConfigDataBase * 功能说明: 为了让代码重用,利用此类可以动态的连接各种数据库 * 参数说明:_hcoder 数据库操作类基于pdo class db { private static $operater; private $t
文章浏览阅读1.7k次,点赞4次,收藏3次。通常我们都将html元素分为块级元素、行内元素以及行内块级元素,但是今天冲浪时发现一个将html元素分类的新名词对——替换元素和非替换元素,其实也可以称为置换元素和非置换元素。接下来就记录一下个人对于这个新名词对的一些浅显见解,如有问题,还望大佬指出~目录一、替换元素1.定义2.举例说明3.替换元素有哪些二、非替换元素1.定义2.举例说明3.非替换元素有哪些一、替换元素1.定义一个内容不受CSS视觉格式化模型控制,CSS渲染模型并不考虑对此内容的渲染,且元素本身一般拥有固有尺寸(宽度,高度,宽高._置换元素和非置换元素
文章浏览阅读1.4w次,点赞5次,收藏21次。VyOS是基于Linux的网络操作系统,可提供基于软件的网络路由,防火墙和VPN功能。VyOS项目于2013年底开始,是Vyatta Core 6.6R1的GPL部分的社区分支,目的是维护一个自由和开源的网络操作系统,以响应终止Vyatta社区版本的决定。在这里,每个人都喜欢学习,老一辈的经理和新用户。VyOS主要基于Debian GNU / Linux和Quagga路由引擎。其配置语法和CLI大致是从XORP项目建模的Juniper JUNOS派生而来的,该项目是Vyatta的原始路由引擎。..._vyos图形界面
文章浏览阅读92次。破世界纪录了 0.74 秒!用 Python 实现自动扫雷!相信许多人很早就知道有扫雷这么一款经典的游(显卡测试)戏(软件),更是有不少人曾听说过中国雷圣,也是中国扫雷第一、世界综合排名第二的郭蔚嘉的顶顶大名。扫雷作为一款在Windows9x时代就已经诞生的经典游戏,从过去到现在依然都有着它独特的魅力:快节奏高精准的鼠标操作要求、快速的反应能力、刷新纪录的快感,这些都是扫雷给雷友们带来的、只属于扫雷的独一无二的兴奋点。▍0x00 准备准备动手制作一套扫雷自动化软件之前,你需要准备如下一些工具/软件_自动扫雷软件
文章浏览阅读2.4k次,点赞4次,收藏12次。这个问题困扰了我很久。今天终于解决了,记录一下。造成这个结果的原因是cuda编译版本与runtime版本不符。安装的是10.0版本,也就是/usr/local/cuda-10.0(默认安装目录)。nvcc -V的结果是7.5。apt list|grep nvidia-cuda-tookit显示版本为7.5,找到原因了。卸载掉sudo apt autoremove nvidia-cuda-toolkit把安装版本加入环境变量export LD_LIBRARY_PATH=$LD_LIBRA_nvcc -v和nvidia -smi输出版本不一样
文章浏览阅读811次,点赞23次,收藏24次。Debug:是供程序员使用的调试工具,它可以用于查看程序的执行流程,也可以用于追踪程序执行过程来调试程序。步骤1:加断点步骤2:运行Debug步骤3:下一步 F7步骤4:结束Debug 点击stop红点Object类是所有类的父类,是java.lang包下的核心类(java.lang下的所有包默认直接导入)所有类都可以继承Object中允许被继承的方法所有java类都是直接或间接集成Object类,如果一个类不继承任何一个类,那么它默认继承Object类。
文章浏览阅读1k次,点赞38次,收藏26次。[Java 27周年] 我与Java的缘善于对自己提问题,这个为什么,那个为什么,只有这样,你才会提升和前进。
文章浏览阅读324次。软件要易于修改:最近在看一本书《代码整洁之道:程序员的职业素养》,这本书里面说到,代码设计要遵循一个重要的原则-易于修改,并且要实现这个目标就应该经常修改它,而不是等到大量积累了臃肿代码之后再进行深度重构。 一套完善的测试用例是修改代码的安全保障:而如何保证在频繁修改优化代码之后,不影响其原本的功能呢?那就是要编写一套完善的测试用例,能覆盖到所有的链路场景,通过测试用例的执行结果来确保代码修改的正确性。特别是我们做金融场景业务的开发,尤其要注意代码的正确性、安全性,那么写好单测是不可或缺的_写单元测试用例的工作经历
文章浏览阅读854次。[导读]说到打印机,相信各位并不陌生,但是轮到使用打印机可怕是许多朋友都未曾接触过的。比如说打印机安装驱动操作方法,电脑如何连接打印机,想必这些是许多朋友的疑问。下面我们就来说说打印机如何安装驱动、电脑如何连接打印机。说到打印机,相信各位并不陌生,但是轮到使用打印机可怕是许多朋友都未曾接触过的。比如说打印机安装驱动操作方法,电脑如何连接打印机,想必这些是许多朋友的疑问。下面我们就来说说打印机如何安..._如何连接电脑与打印机并正确安装打印机驱动
文章浏览阅读2.5k次。我的源码 public Session getCurrentSession() { Session session = null; System.out.println("这是baseDao的session"); try { session = sessionFactory.getCurrentSession(); } catch (Exception e) { // ..._illegalargumentexception: removing a detached instance
文章浏览阅读1w次。create or replace procedure proc1isp_name sut.name%type;beginselect name into p_name from sut where id='12072226';dbms_output.put_line(p_name);end proc1;/注意定义方式_oracle写存储过程怎么定义变量