Spring学习笔记(较长,可以按照目录看有需要的部分~)

【spring大总结】希望所有看完这篇文章的C友,都能快速入门spring Spring快速入门1.spring1.1.优点1.2.缺点1.3.Spring框架的组成结构图1.3.1.核心容器1.3.2.AOP 和设备支持1.3.3.数据访问与集成1.3.4.Web1.3.5.消息(Messaging)1.3.6.Test2.Spring核心ioc2.1.ioc容器2.1.BeanFactory 容器2.1.2\. ApplicationContext 容器2.1.2.1.ClassPathXmlApplicationContext2.1.2.2.FileSystemXmlAppl 阅读详情

简介

Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架。spring作为容器去管理你的类,有spring管理的类在整个服务器启动期间在内存中只生成一份。

1、IoC介绍

控制反转 Inverse of Control, 一个xml文件就相当于一个Spring容器,在xml文件中部署所有bean,在类中利用annotation注释插入值

2、关于注解@Xx的使用

ps: 注解需要有aop包的导入,@Autowired 使用较普遍,@Value

[(img-OJtXRpod-1619186502454)(C:\Users\Razer\AppData\Roaming\Typora\typora-user-images\image-20210309111029964.png)]

1.1 @Component 作用及使用方法

当@Component标注在类上时,该类可无需在xml文件中进行bean配置 ,效果等同于如下

<bean id="xx" class="xx"><bean> 

在类中配置实例如下:

@Component("User") //注解加在类上
public class User {
    public String name="Jack";

    @Value("strrr")   //可以这样子注入普通值
    public String str;
}

但需要在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
        https://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.kuang"></context:component-scan> <!--    指定扫描这个包,此包下注解生效-->
    <context:annotation-config/>
</beans>

1.2 @Component 使用时bean id的命名规则:

  • 当类名开头只有一个大写字母时,bean id会生成为类名首字母小写
  • 当类名同时有两个及以上大写字母时,bean id为原类名
  • 可以使用@Component(“ bean_id") 指定

2、@Component有三个衍生注解 适用于MVC三层架构分开注解,但其实作用都一致

  • 1、controller [ @Controller ]
  • 2、service 【 @Service 】
  • 3、dao 【 @Repository 】

3、@Configuration的使用

在类中进行如此注解,则可在一个类中注解多个bean

@Configuration
public class JackConfig2 {

    @Bean(name = "UserG2")   //相当于这份xml文件里的 bean标签,默认bean idr就是方法名UserGenerato,返回值User就是class
    public User UserGenerator(){
        return new User();  //User()会引用 <bean id="User” class=“com.kuang.pojo.User">,从而返回一个已经注入好的user
    }

    @Bean(name = "Show")
    public void Show(){
        System.out.println("this is show method");
    }
}

4、完全无xml文件的使用方法


前提是需要使用到的bean都使用了@Component 或者是@Configuration来注解声明! ! !

在主函数使用AnnotationConfigApplicationContext来构建context

 public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("com.kuang");
      //路径是包,会扫描这个包及子包内的所有注解
       
        User user = (User) context.getBean("USER");
        System.out.println(user.getName());
 }
   

5、小结

  • 对于Spring项目, xml文件更加易于维护
  • 缺点有:不是自己类使用不了 。注解是Spring Boot常用的,
  • 所以最佳实践一般xml文件用来管理bean,注解用来注入值

3、AOP (Aspect Oriented Programming)面向切面编程

3.1设计的原因

就是为了防止原业务代码被改动,假设纵向开发已然完成,一般不允许代码被改动,而想要在原有代码上面增加功能,则需要设置一代理去代理service,并在代理里做增加

3.2静态代理

  • 可参考com.kuang.spring-08-proxy 中的demo2_realProxy中的Proxy.class是如何代理UserServiceImpl.class的

3.3 动态代理

参考com.kuang.spring-08-proxy 中的demo3_dynamic

通过一个自建类去implements 接口InvocationHandler

public class ProxyInvocationHandler implements InvocationHandler {

    private Object target;  //被代理的接口!
    public void setTarget(Object target) {
        this.target = target;
    }

    //几乎固定代码,来生成得到代理类
    public Object getProxy(){
        return Proxy.newProxyInstance(this.getClass().getClassLoader(),
                target.getClass().getInterfaces(),  //此时这里是已被implement的接口实现类
                this);
    }

    //处理代理实类,并返回结果。 (可在此加入想要加入的功能)
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { //这是接口InvocationHandler里的方法
        //动态代理的本质就是使用反射机制来实现!
        Object result=method.invoke(target,args);
         log(method.getName());  //可以增加自己想要的功能
        seeHouse(); //可以增加自己想要的功能
        return result;
    }

    public void seeHouse(){
        System.out.println("中介带你看房");
    }
    public void log(String msg){
    System.out.println("这里使用了method: "+msg);
}

在主函数中通过注入任意一个 接口实现类,便能使用此接口实现类中的方法

public static void main(String[] args) {
        //这是一个真实角色
        Landlord landlord = new Landlord();
       //代理角色此时还没有出现
        ProxyInvocationHandler pih = new ProxyInvocationHandler();
        pih.setTarget(landlord); //注入Rent的实现类landlord,


        Rent proxy = (Rent) pih.getProxy();       //代理角色出现了,被动态生成
        proxy.rent(); //可以使用接口实现类里的任何方法
    }

相比之与静态配置的优点:

一个动态代理类 代理的是一个***接口***(一般对应一类业务)

且可以代理所有实现了这个接口的类

4、使用Spring实现AOP

4.1 使用Spring API原生接口

<!--    方法1: 使用原生Spring API接口-->
    <aop:config>
<!--        设置切入点-->
        <aop:pointcut id="pointcut" expression="execution(
* com.kuang.service..*.*(..))"/>

<!--        在切入点前后给出advice-->
        <aop:advisor advice-ref="log" pointcut-ref="pointcut"></aop:advisor>
        <aop:advisor advice-ref="logAfter" pointcut-ref="pointcut"></aop:advisor>

    </aop:config>

4.2 自定义类来实现aspect切入,可理解为类切入

<bean id="diyPointcut" class="com.kuang.diy.DiyPointcut"></bean>

    <!--    方法2: 使用自定义类切入-->
    <aop:config>
        <!--        aspect切入 是类切入-->
       <aop:aspect ref="diyPointcut">
           
       <!--    pointcut设置切入点-->
            <aop:pointcut id="pointcut" expression="execution(                              * com.kuang.service..*.*(..))"/>
           
<!--        增加的method-->
           <aop:before method="DiyBefore" pointcut-ref="pointcut"></aop:before>
           <aop:after method="DiyAfter" pointcut-ref="pointcut"></aop:after>
       </aop:aspect>
        
    </aop:config>

4.3.1 注解使用AOP如何配置

4.3.1.1

方法1:自定义类切入

自定义类DiyPointcut如下

public class DiyPointcut {
    public  void DiyAfter(){
        System.out.println("---after method----");
    }
    public void DiyBefore(){
        System.out.println("---before method----");
    }
}

配置文件applicationContext2.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: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/aop https://www.springframework.org/schema/aop/spring-aop.xsd">

    <bean id="usImpl" class="com.kuang.service.UserServiceImpl"></bean>
   <bean id="diyPointcut" class="com.kuang.diy.DiyPointcut"></bean>

    <!--    方法2: 使用自定义类切入-->
    <aop:config>
        <!--        aspect切入 是类切入,此处切入类是com.kuang.diy.DiyPointcut-->
       <aop:aspect ref="diyPointcut">
       <!--    pointcut设置切入点-->
            <aop:pointcut id="pointcut" expression="execution(* com.kuang.service..*.*(..))"/>
    
<!--        增加的method-->
           <aop:before method="DiyBefore" pointcut-ref="pointcut"></aop:before>
           <aop:after method="DiyAfter" pointcut-ref="pointcut"></aop:after>
       </aop:aspect>

    </aop:config>
</beans>

在主函数test2调用如下:

public static void main(String[] args) {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext2.xml");

    //注意!! 动态代理的是接口
    UserService usImpl = (UserService) context.getBean("usImpl");
    usImpl.add();
}

运行截图如下:

在这里插入图片描述

4.3.1.2

方法2:利用@Aspect,在切面类中配置。

(且@Aspect需在xml文件中激活)

@Aspect  //使用切面的注解
public class AnnotationPointcut {
    @After("execution(* com.kuang.service..*.*(..))")   //注意要用的是aop的包 ,别用从junit
    public  void AnnoAfter(){
        System.out.println("---after method by Annotation----");
    }
    
    @Before("execution(* com.kuang.service..*.*(..))")
    public void AnnoBefore(){
        System.out.println("---before method by Annotation----");
    }
    
    @Around("execution(* com.kuang.service..*.*(..))")
    public void around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("before around by Annotation");
        Object proceed = joinPoint.proceed();  //接入点
        System.out.println("after around by Annotation");
    }
}

applicationContext3.xml中激活@Aspect的配置如下:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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/aop https://www.springframework.org/schema/aop/spring-aop.xsd">

<!--    第三种方法,使用注解AOP-->
    
<!--    配置自动代理功能    -->
    <aop:aspectj-autoproxy></aop:aspectj-autoproxy>
</beans>

<!-- bean的配置-->
<bean id="annotationPointcut" class="com.kuang.diy.AnnotationPointcut"></bean>
    <bean id="usImpl" class="com.kuang.service.UserServiceImpl"></bean>

在主函数中test3这样调用:

public static void main(String[] args) {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext3.xml");
    UserService usImpl = (UserService) context.getBean("usImpl");
 usImpl.delete();

运行结果截图如下:
在这里插入图片描述

4.3.1.3

方法3:@EnableAspectJAutoProxy 配置在切面类上即可使用(无需xml文件)

切面类AnnotationPointcut如下:

@Aspect  //使用切面的注解
@Component
@EnableAspectJAutoProxy //使用此注解则无需在xml文件中配置自动代理
public class AnnotationPointcut {
    @After("execution(* com.kuang.service..*.*(..))")   //注意要用的是aop的包 ,别用从junit
    public  void AnnoAfter(){
        System.out.println("---after method by Annotation----");
    }
    @Before("execution(* com.kuang.service..*.*(..))")
    public void AnnoBefore(){
        System.out.println("---before method by Annotation----");
    }
    @Around("execution(* com.kuang.service..*.*(..))")
    public void around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("before around by Annotation");

        Object proceed = joinPoint.proceed();  //接入点

        System.out.println("after around by Annotation");
    }
}

Note: 被切入的类UserServiceImpl需要@Component来注解存在(这样子UserServiceImpl便无需在xml文件中配置bean id。

被切入类UserServiceImpl如下:

@Component("usImpl")
public class UserServiceImpl implements UserService {
    public void add() {
        System.out.println("实现操作add");
    }

    public void delete() {
        System.out.println("实现操作delete");
    }

    public void update() {
        System.out.println("实现操作update");
    }

    public void select() {
        System.out.println("实现操作select");
    }
}

在主函数test4_EnableAspectAutoProxy中使用AnnotationConfigApplicationContext来生成context,

public static void main(String[] args) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("com.kuang");
    UserService usImpl = (UserService) context.getBean("usImpl");
    usImpl.delete();
}

效果与4.3.1.2相同,减少了xml文件的配置

*4.4 execution()表达式

expression="execution(* com.kuang.service..*.*(..))"
  • 第一个形参表示返回类型, *号表示所有的类型
  • 第二个形参为需要拦截的包名,后面的两个句点表示当前包和当前包的所有子包
    • 即com.kuang.service包和其子孙包下所有类的方法。
  • 第三个形参表示类名, ( *号表示所有的类 )
  • ​ .*(…) 最后这个星号表示方法名,*号表示所有的方法,后面括弧里面表示方法的参数,两个句点表示任何参数

Note: .* 之间不能有空格

5、事务Transaction

事务要满足ACID四大特性

  • 原子性(atomicity) 事务是一个不可分割的工作单位,事务中的操作要么全部成功,要么全部失败
  • 、一致性(consistency)事务必须使数据库从一个一致性状态变换到另外一个一致性状态。(事务按照预期生效,数据的状态是预期的状态)
  • 、隔离性(isolation)事务执行过程中对数据的修改,在事务提交之前对其他事务不可见(多个并发事务之间要相互隔离)
  • 持久性(durability)一个事务一旦被提交成功,它对数据库中数据的改变就是永久性的,接下来即使数据库发生故障也不应该对其有任何影响

事务从数据库角度说,就是一组SQL指令,要么全部执行成功,若因为某个原因其中一条指令执行有错误,则撤销先前执行过的所有指令。更简答的说就是:要么全部执行成功,要么撤销不执行

5.1 Spring编程式事务

5.2 Spring声明式事务

*常用配置关系代码

当依赖出错时,在C:\Users\Razer.m2\repository 中找到jar包删除,然后在idea中刷新重新下载导入

在最外层Project的pom.xml 文件中配置

  <dependency>
        <!-- 若无法自动导入jar包则去此网址 https://mvnrepository.com/artifact/org.springframework/spring-webmvc  -->
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>5.2.0.RELEASE</version>
    </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
         <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.9.4</version>
        </dependency>

*applicatonContext.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
        https://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.kuang"></context:component-scan> <!--    指定扫描这个包,此包下注解生效-->
    <context:annotation-config/>
</beans>

BurpSuite实战:5分钟搞定Pikachu靶场表单爆破(附最新字典配置技巧) 本文通过Pikachu靶场实战,详细演示了如何使用BurpSuite的Intruder模块对Web登录表单进行暴力破解。从代理配置、请求捕获、集束炸弹模式设置,到载荷配置与结果分析,提供了完整的操作流程。文中还分享了2024年有效的字典获取与优化技巧,帮助安全测试人员快速定位弱口令漏洞。 阅读详情

相关推荐

SRCNN超分辨率Pytorch实现,代码逐行讲解,附源码

超分辨率,就是把低分辨率(LR, Low Resolution)图片放大为高分辨率(HR, High Resolution)的过程。通过CNN将图像Y 的特征提取出来存到向量中。用一层的CNN以及ReLU去将图像Y 变成一堆堆向量,即feature map。把提取到的特征进一步做非线性映射,加大网络深度,提高网络复杂性。结合了前面得到的补丁来产生最终的高分辨率图像。实验步骤。

weixin_52261094的博客 3万+

Spring的schema列表

最近在看Spring的项目,发现在bean.xml中都有加载很多来自www.springframework.org的schema如: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:contex...

weixin_30835923的博客 121

11、基于拓扑质心和树编辑距离的RNA二级结构比较方法

本文介绍了一种基于拓扑质心和树编辑距离的RNA二级结构比较方法,特别适用于处理具有假结结构的RNA。通过PEELING算法识别拓扑质心并将其转换为树结构,结合树编辑距离进行高效比较,并提供工具planeGraph2tree实现该方法。博文详细描述了方法原理、操作流程以及应用示例,展示了其在功能性非编码RNA分析中的实用性。

resnet7explorer的博客 111

Spring学习笔记(四)--spring配置文件schema约束

强烈推荐一个大神的人工智能的教程:http://www.captainbed.net/zhanghan 相关概念 在使用spring的配置文件时,新添加一个配置文件就需要添加相应的约束,一直没有研究过为什么要有这些约束,这些约束是干什么的。spring在启动的时候需要验证xml文档,约束的作用就是来验证配置文件的xml文档语法的正确性。 在项目中其中的一个spring配置文件约...

至尊宝 3万+

LFI Scanner 本地文件包含漏洞扫描、文件路径遍历、敏感文件读取(etcpasswd)

✅ **敏感文件读取验证**:内置`/etc/passwd、/windows/system32/drivers/etc/hosts、phpinfo.php`等敏感文件字典,一键验证漏洞可利用性;🔴 **Windows**:`/windows/win.ini`(系统配置)、`/windows/system32/drivers/etc/hosts`;🔴 **Linux**:`/etc/passwd`(用户信息)、`/proc/version`(内核版本)、`/etc/hosts`(域名解析);

寒寒豆豆软件公司的博客 130

STM32 cubeMX配置串口重定向

这篇文章主要讲解什么是串口重定向,为什么要串口串口重定向。使用printf函数和上位机通信是非常的方便的。希望大家都能够掌握。

m0_49476241的博客 4571

Spring cloud gateway 详解和配置使用(文章较长)

目录 spring cloud gateway 介绍 1. 网关是怎么演化来的 2. 网关的基本功能 3.关于Spring Cloud Gateway 4.Spring Cloud Gateway 功能特征 5.predicate简介 6.GatewayFilter 工厂介绍 7.集成Hystrix的断路器功能 8.请求限流 pom.xml application.ym...

荡漾 21万+

使用linuxdeployqt打包Qt程序问题及解决方法

安装过程中提示缺少依赖multiarch-support: 下载对应依赖包。安装过程中提示缺少libpq.so.5: 下载对应依赖包。下载libmysqlclient18/5.6.25。

weixin_74239923的博客 1058

《Spring学习笔记》:Spring、Hibernate、struts2的整合(以例子来慢慢讲解,篇幅较长)

《Spring学习笔记》:Spring、Hibernate、struts2的整合(以例子来慢慢讲解,篇幅较长)最近在看马士兵老师的关于Spring方面的视频,讲解的挺好的,到了Spring、Hibernate、struts2整合这里,由于是以例子的形式来对Spring+Hibernate+struts2这3大框架进行整合,因此,自己还跟着写代码的过程中,发现还是遇到了很多问题,因此,就记录下。特此说

wojiushimogui的博客 5957

LVGL misc timer 定时器(lv_timer.c)

定时器机制是LVGL中非常重要的一项功能,它承载了LVGL的延时任务执行,周期任务执行,时序任务执行等,可以说理解定时器的设计就一定程度上理解发LVGL的任务调度机制。

Bigan(安)的博客 4729

华为OD机试真题 新系统 2026-04-19 Java&Go 实现【分辨率排序】

华为OD机试真题 新系统 2026-04-19 Python&JS 实现【分辨率排序】

MISAYAONE的博客 303

本地启动SpringBoot服务耗时较长问题的解决方案

解决本地启动Springboot服务耗时很长的问题

MNHKL的博客 1586

2026年算法工程师常见面试简答题

本文摘要:文章系统梳理了机器学习与深度学习中的30个核心概念,涵盖模型优化、评估指标、经典算法和大模型应用等关键知识点。主要内容包括:1)过拟合与欠拟合的成因及解决方法;2)偏差-方差权衡原理;3)数据划分与交叉验证策略;4)分类/回归任务评估指标选择;5)逻辑回归、决策树、SVM等传统算法解析;6)梯度下降优化与正则化技术;7)CNN、RNN、Transformer架构对比;8)Embedding表示与RAG技术。特别强调面试高频考点如XGBoost改进、注意力机制原理等,并给出实际工程中的解决方案建议,

不务正业的猿 349

Spring基于注解的IOC初始化过程(较长慎入)

Spring中基于注解的IOC容器初始化过程 文章目录Spring中基于注解的IOC容器初始化过程入口AnnotationConfigApplicationContext一:初始化之构造方法——this()初始化的第一步二:初始化之——register(componentClasses)总结:三:初始化的关键——refresh()1,准备工作——prepareRefresh()2,获取BeanFactory——obtainFreshBeanFactory()2.1,refreshBeanFactory()2

qq_41868309的博客 391

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

Spring Cloud Gateway 详解和配置使用(文章较长)

spring cloud gateway 介绍 1. 网关是怎么演化来的 单体应用拆分成多个服务后,对外需要一个统一入口,解耦客户端与内部服务 注:图片来自网络 2. 网关的基本功能 网关核心功能是路由转发,因此不要有耗时操作在网关上处理,让请求快速转发到后端服务上 网关还能做统一的熔断、限流、认证、日志监控等 注:图片来自网络 可以和服务注册中心完美的整合,如:Eureka、Consul、Nacos 3.关于Spring Cloud Gateway 在SpringCloud微服务体系中

u011997561的博客 763

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Spring学习笔记

什么是Spring? 什么是Spring?Spring就是一个用于企业开发的、轻量级的、开源的javaEE框架,主要为了解决企业应用开发的复杂性。 Spring的优缺点? 优点: 1,降低了组件之间的耦合性,实现了软件各层之间的解耦。 2,可以使用容器提供的众多服务,如事务管理,消息服务等。 3,容器提供单例模式支持。 4,容器提供了AOP技术,利用它可以很容易实现一些拦截,如权限拦截,运行期监控等。 5,容器提供了众多的辅助类,能够加快应用的开发。 6,spring对于主流的应用框架提供了很好的支持,例如

qq_43797044的博客 307

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

java学习笔记————Spring总结

Spring

qq_54177999的博客 555

Spring Native入门

spring-native介绍 背景: Spring 团队日前发布了 Spring Native Beta 版。通过 Spring Native,Spring 应用将有机会以 GraalVM 原生镜像的方式运行。为了更好地支持原生运行,Spring Native 提供了 Maven 和 Gradle 插件,并且提供了优化原生配置的注解。 特点: 基于native images: GraalVM进行代码编译优点: 1.立即启动,一般启动时间小于100ms 2.更低的内存消耗 3.独立部署,不再需要JV.

叶星源的博客 1万+

Spring Bean加载耗时采集工具

针对启动慢的 Spring 应用,找出 IOC 容器启动过程中,加载耗时较长的 Bean 对象进行治理。

兴趣使然的草帽路飞 6586

详解Spring AOP

Aspect Oriented Programming(面向切面编程),OOP是面向对象编程(开发的时候把一个个都抽象成对象来开发),两者的维度不同,处理的事情不同切⾯就是指某⼀类特定问题, 所以AOP也可以理解为⾯向特定⽅法编程。面向切面编程就是针对某一类特定问题统一进行编程比如people类有自己的属性和行为,但是有小一部分人生病要去医院看病,看病这个业务逻辑就不属于哪一个类,因为people泛指所有人,所有人不会都看病。

N_0050的博客 2030

Spring 代码性能分析工具 StopWatch

平时总能遇到一些性能低、耗时久的代码,通过使用Spring 自带的工具类可以进行监控定位到耗时较长的代码片段,便于优化,直接上代码: public void testStopWatch() { StopWatch stopWatch = new StopWatch(); // 复杂业务逻辑 .... stopWatch.start("证件号、手机号去重"); if (visitorPersonSaveBeforeValidata(idCard, phone)) return res; s

搬运Gong 515

学习笔记整理(部分)

技术要点摘要 对象创建与存储 new操作流程:分配堆内存→调用构造函数→返回对象引用 对象存储:实例在堆区,引用在栈区 Spring创建方式:构造器/工厂方法/XML配置/注解自动装配 性能排查 CPU 100%排查:定位高负载进程→分析线程堆栈→优化问题代码 慢查询优化:检查执行计划→优化索引/SQL→分析服务器资源 缓存与安全 Redis签到设计:使用Bitmap存储,key格式sign:user_id:年月 JWT签名:验证令牌真实性,防篡改 数据结构与测试 ArrayList vs LinkedLi

2301_80381519的博客 586

MacOS环境下IDEA安装spring-boot-devtools热部署以及自动热部署时间较长的问题

IDEA自动热部署,配置以及解决时间加载较长问题

劲雨波 960

Spring入门看这一篇就够了

Spring1、Spring框架体系2、 IOC2.1 什么是IOC2.3 基于配置文件的di实现2.3.1 什么是di2.3.2 入门案例2.3.3 环境搭建2.3.4 案例总结2.3.5 简单类型属性的赋值(set注入)在入门案例的总结我们说过了spring容器默认是使用无参构造构造来实例化对象的,那么对象的属性必定为初始值,例如int类型为0,boolean类型为false等,那么当我们想使用相关属性进行操作时必然要手动使用set方法给属性赋值,那么有没有办法让容器帮我们完成对象属性的赋值呢?让我们直

遇妳 3556

Spring AOP

AOP(Aspect-Oriented Programming,面向切面编程):是一种软件开发的编程范式,旨在将横切关注点(cross-cutting concerns)与核心业务逻辑分离,以提高代码的模块化性、可维护性和复用性

2301_76161469的博客 5324

java form 400_springMVC表单post提交较长字符串显示400错误?

POST提交较短字符串时没问题,稍长字符串就显示400错误,修改tomcat的server.xml没用表单只有如下两个字段,这个content长度就会报错控制器代码//处理新闻评论表单提交@RequestMapping(value = "/news", method = RequestMethod.POST)public String doReplyNews(@Validated NewsRepl...

weixin_36387104的博客 299
上一篇: 关于集合中各种接口,类之间的关系
下一篇: JVM学习笔记
老邓CODING
博客等级 码龄8年 9粉丝 33原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值