【Spring】——9、如何指定初始化和销毁的方法?

news2024/10/7 16:16:42

在这里插入图片描述

📫作者简介:zhz小白
公众号:小白的Java进阶之路
专业技能:
1、Java基础,并精通多线程的开发,熟悉JVM原理
2、熟悉Java基础,并精通多线程的开发,熟悉JVM原理,具备⼀定的线上调优经验
3、熟悉MySQL数据库调优,索引原理等,⽇志原理等,并且有出过⼀篇专栏
4、了解计算机⽹络,对TCP协议,滑动窗⼝原理等有⼀定了解
5、熟悉Spring,Spring MVC,Mybatis,阅读过部分Spring源码
6、熟悉SpringCloud Alibaba体系,阅读过Nacos,Sentinel,Seata,Dubbo,Feign,Gateway核⼼源码与设计,⼆次开发能⼒
7、熟悉消息队列(Kafka,RocketMQ)的原理与设计
8、熟悉分库分表ShardingSphere,具有真实⽣产的数据迁移经验
9、熟悉分布式缓存中间件Redis,对其的核⼼数据结构,部署架构,⾼并发问题解决⽅案有⼀定的积累
10、熟悉常⽤设计模式,并运⽤于实践⼯作中
11、了解ElasticSearch,对其核⼼的原理有⼀定的了解
12、了解K8s,Jekins,GitLab
13、了解VUE,GO
14、⽬前有正在利⽤闲暇时间做互游游戏,开发、运维、运营、推销等

本人著作git项目:https://gitee.com/zhouzhz/star-jersey-platform,有兴趣的可以私聊博主一起编写,或者给颗star
领域:对支付(FMS,FUND,PAY),订单(OMS),出行行业等有相关的开发领域
🔥如果此文还不错的话,还请👍关注、点赞、收藏三连支持👍一下博主~

文章目录

  • 1、Bean的生命周期整体流程
  • 2、如何定义初始化和销毁方法?
    • 2.1、通过@Bean注解指定初始化和销毁方法。
      • 2.1.1、单例Bean的初始化和销毁
        • 2.1.1.1、添加对象
        • 2.1.1.2、添加配置类
        • 2.1.1.3、添加测试类
        • 2.1.1.4、运行结果
        • 2.1.1.5、总结
      • 2.1.2、多例Bean的初始化和销毁
        • 2.1.2.1、添加对象
        • 2.1.1.2、添加配置类
        • 2.1.1.3、添加测试类
        • 2.1.1.4、运行结果
        • 2.1.1.5、其他
    • 2.2、使用InitializingBean和DisposableBean
      • 2.2.1、了解InitializingBean
        • 2.2.1.1、总结
      • 2.2.2、了解DisposableBean
        • 2.2.2.1、总结
      • 2.2.3、实践
        • 2.2.3.1、单实例bean的初始化与销毁
          • 2.2.3.1.1、创建对象
          • 2.2.3.1.2、创建配置类
          • 2.2.3.1.3、创建测试类
          • 2.2.3.1.4、运行结果
          • 2.2.3.1.5、总结
        • 2.2.3.2、多实例bean的初始化与销毁
          • 2.2.3.2.1、创建对象
          • 2.2.3.2.2、创建配置类
          • 2.2.3.2.3、创建测试类
          • 2.2.3.2.4、运行结果
          • 2.2.3.2.5、总结
  • 3、指定初始化和销毁方法的使用场景
  • 4、初始化和销毁方法调用的时机

1、Bean的生命周期整体流程

对于一个SpringBean来说,他会整体经过以下流程,才会创建一个完整的Bean
在这里插入图片描述
简略为:

  • 1、 实例化(Instantiation)
  • 2、 属性设置(populate)
  • 3、 初始化(Initialization)–类调用
  • 4、 销毁(Destruction)–容器关闭

2、如何定义初始化和销毁方法?

我们这次主要是针对SpringBean的最后两步讲解,就是Bean的初始化,和销毁。
具体怎么操作,我们只需要对

  • 通过@Bean注解指定初始化和销毁方法。
  • 使用InitializingBean和DisposableBean

2.1、通过@Bean注解指定初始化和销毁方法。

2.1.1、单例Bean的初始化和销毁

2.1.1.1、添加对象

package com.zhz.bean;

import lombok.*;

/**
 * @author zhouhengzhe
 * @description: 实体类
 * @date 2022/11/4 10:12
 * @since v1
 */
@Data
@AllArgsConstructor
@Builder
public class Person {
    private String name;
    private Integer age;

    public void init() {
        System.out.println("Person初始化完成");
    }

    public void destroy() {
        System.out.println("Person销毁成功");
    }

    public Person() {
        System.out.println("初始化构造方法");
    }
}

2.1.1.2、添加配置类

package com.zhz.config;

import com.zhz.bean.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 生命周期相关配置
 * @author zhouhengzhe
 * @date 2022/11/21
 */
@Configuration
public class MainConfigByLifeCycle {

    @Bean(initMethod = "init",destroyMethod = "destroy")
    public Person person(){
        return new Person();
    }
}

2.1.1.3、添加测试类

 @Test
    public void test4ByLiseCycle(){
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfigByLifeCycle.class);
        System.out.println("容器创建完成");
        applicationContext.close();
    }

2.1.1.4、运行结果

在这里插入图片描述

2.1.1.5、总结

我们可以发现,Spring的Bean在单例的时候,他会按顺序执行

  • 初始化构造
  • 初始化完成
  • Bean销毁(容器关闭的时候)

2.1.2、多例Bean的初始化和销毁

2.1.2.1、添加对象

package com.zhz.bean;

import lombok.*;

/**
 * @author zhouhengzhe
 * @description: 实体类
 * @date 2022/11/4 10:12
 * @since v1
 */
@Data
@AllArgsConstructor
@Builder
public class Person {
    private String name;
    private Integer age;

    public void init() {
        System.out.println("Person初始化完成");
    }

    public void destroy() {
        System.out.println("Person销毁成功");
    }

    public Person() {
        System.out.println("初始化构造方法");
    }
}

2.1.1.2、添加配置类

package com.zhz.config;

import com.zhz.bean.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 生命周期相关配置
 * @author zhouhengzhe
 * @date 2022/11/21
 */
@Configuration
public class MainConfigByLifeCycle {

    @Scope("prototype")
    @Bean(initMethod = "init",destroyMethod = "destroy")
    public Person person(){
        return new Person();
    }
}

2.1.1.3、添加测试类

 @Test
    public void test4ByLiseCycle(){
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfigByLifeCycle.class);
        System.out.println("容器创建完成");
        applicationContext.close();
    }

2.1.1.4、运行结果

在这里插入图片描述

我们可以发现在类没有去调用的话,就不会有类的构造方法,初始化的引用。

2.1.1.5、其他

然后我们再看一下,创建类的时候,代码如下:

 @Test
public void test4ByLiseCycle(){
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfigByLifeCycle.class);
    System.out.println("容器创建完成");
    Person bean = applicationContext.getBean(Person.class);
    applicationContext.close();
}

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

我们可以发现Spring的Bean在多例的情况下,Spring容器不会管理这个bean,也就不会自动调用这个bean的销毁方法。

2.2、使用InitializingBean和DisposableBean

2.2.1、了解InitializingBean

  • InitalizingBean是Spring提供给用户的一个扩展性接口,该接口为bean提供了属性初始化后的处理方法,它只包括afterPropertiesSet方法,凡是继承该接口的类,在bean的属性初始化后都会执行该方法。

其主要源码如下:

/*
 * Copyright 2002-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.beans.factory;

/**
 * Interface to be implemented by beans that need to react once all their properties
 * have been set by a {@link BeanFactory}: e.g. to perform custom initialization,
 * or merely to check that all mandatory properties have been set.
 *
 * <p>An alternative to implementing {@code InitializingBean} is specifying a custom
 * init method, for example in an XML bean definition. For a list of all bean
 * lifecycle methods, see the {@link BeanFactory BeanFactory javadocs}.
 *
 * @author Rod Johnson
 * @author Juergen Hoeller
 * @see DisposableBean
 * @see org.springframework.beans.factory.config.BeanDefinition#getPropertyValues()
 * @see org.springframework.beans.factory.support.AbstractBeanDefinition#getInitMethodName()
 */
public interface InitializingBean {

	/**
	 * Invoked by the containing {@code BeanFactory} after it has set all bean properties
	 * and satisfied {@link BeanFactoryAware}, {@code ApplicationContextAware} etc.
	 * <p>This method allows the bean instance to perform validation of its overall
	 * configuration and final initialization when all bean properties have been set.
	 * @throws Exception in the event of misconfiguration (such as failure to set an
	 * essential property) or if initialization fails for any other reason
	 * 用于属性赋值之后调用。
	 */
	void afterPropertiesSet() throws Exception;

}

在上面源码中,afterPropertiesSet()方法是在属性赋值之后调用的,那么他究竟是在哪调用的呢?我们直接看源码,我们直接全局搜索,可以发现他是这个以下这份代码初始化的。大家有兴趣的可以直接搜一下方法。我这里给大家往前推一下代码:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#invokeInitMethods
在这里插入图片描述

他的上层方法调用是以下方法:
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#initializeBean
在这里插入图片描述

再往上推一步就是org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#doCreateBean这个方法,大家有兴趣可以看一下。

2.2.1.1、总结

  • Spring为bean提供了两种初始化的方式,实现InitializingBean接口(也就是要实现该接口中的afterPropertiesSet方法),或者在配置文件或@Bean注解中通过init-method来指定,两种方式可以同时使用。
  • 实现InitializingBean接口是直接调用afterPropertiesSet()方法,与通过反射调用init-method指定的方法相比,效率相对来说要高点。但是init-method方式消除了对Spring的依赖。前者对Spring容器耦合高,效率高;后者利用反射,但是对Spring的耦合低,他是利用反射来解决的,但是效率低。
  • 如果调用afterPropertiesSet方法时出错,那么就不会调用init-method指定的方法了。
  • 两种方式同时使用,则会先调用afterPropertiesSet方法,再调用init-method指定的方法。

2.2.2、了解DisposableBean

实现org.springframework.beans.factory.DisposableBean接口会再bean销毁前,spring才会调用org.springframework.beans.factory.DisposableBean#destroy方法。
我们先看其源码,代码如下:

/*
 * Copyright 2002-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.beans.factory;

/**
 * Interface to be implemented by beans that want to release resources on destruction.
 * A {@link BeanFactory} will invoke the destroy method on individual destruction of a
 * scoped bean. An {@link org.springframework.context.ApplicationContext} is supposed
 * to dispose all of its singletons on shutdown, driven by the application lifecycle.
 *
 * <p>A Spring-managed bean may also implement Java's {@link AutoCloseable} interface
 * for the same purpose. An alternative to implementing an interface is specifying a
 * custom destroy method, for example in an XML bean definition. For a list of all
 * bean lifecycle methods, see the {@link BeanFactory BeanFactory javadocs}.
 *
 * @author Juergen Hoeller
 * @since 12.08.2003
 * @see InitializingBean
 * @see org.springframework.beans.factory.support.RootBeanDefinition#getDestroyMethodName()
 * @see org.springframework.beans.factory.config.ConfigurableBeanFactory#destroySingletons()
 * @see org.springframework.context.ConfigurableApplicationContext#close()
 */
public interface DisposableBean {

	/**
	 * Invoked by the containing {@code BeanFactory} on destruction of a bean.
	 * @throws Exception in case of shutdown errors. Exceptions will get logged
	 * but not rethrown to allow other beans to release their resources as well.
	 */
	void destroy() throws Exception;

}

2.2.2.1、总结

  • 多实例bean的生命周期不归Spring容器来管理,这里的DisposableBean接口中的方法是由Spring容器来调用的,所以如果一个多实例bean实现了DisposableBean接口是没有啥意义的,因为相应的方法根本不会被调用,当然了,在XML配置文件中指定了destroy方法,也是没有任何意义的。所以,在多实例bean情况下,Spring是不会自动调用bean的销毁方法的。

2.2.3、实践

2.2.3.1、单实例bean的初始化与销毁

2.2.3.1.1、创建对象

首先我们创建一个对象,他实现了InitializingBean和DisposableBean,代码如下:

package com.zhz.bean;

import lombok.*;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

/**
 * @author zhouhengzhe
 * @description: 实体类
 * @date 2022/11/4 10:12
 * @since v1
 */
@Data
@AllArgsConstructor
@Builder
public class Person implements InitializingBean, DisposableBean {
    private String name;
    private Integer age;

    public Person() {
        System.out.println("初始化构造方法");
    }

    /**
     * 会在bean创建完成,并且属性都赋好值以后进行调用
     *
     * @throws Exception
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("属性赋值之后调用");
    }

    /**
     * 会在容器关闭的时候进行调用
     *
     * @throws Exception
     */
    @Override
    public void destroy() throws Exception {
        System.out.println("调用销毁");
    }
}
2.2.3.1.2、创建配置类

然后,在MainConfigByLifeCycle配置类中通过包扫描的方式将以上类注入到Spring容器中。

package com.zhz.config;

import com.zhz.bean.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* 生命周期相关配置
* @author zhouhengzhe
* @date 2022/11/21
*/
@Configuration
    public class MainConfigByLifeCycle {

        //    @Scope("prototype")
        @Bean
        public Person person(){
            return new Person();
        }
    }

2.2.3.1.3、创建测试类

让我们写一个测试类,代码如下:

@Test
    public void test4ByLiseCycle(){
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfigByLifeCycle.class);
        System.out.println("容器创建完成");
        Person bean = applicationContext.getBean(Person.class);
        applicationContext.close();
    }
2.2.3.1.4、运行结果

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

2.2.3.1.5、总结
  • 单实例bean情况下,IOC容器创建完成后,会自动调用bean的初始化方法;而在容器销毁前,会自动调用bean的销毁方法。

2.2.3.2、多实例bean的初始化与销毁

2.2.3.2.1、创建对象

首先我们创建一个对象,他实现了InitializingBean和DisposableBean,代码如下:

package com.zhz.bean;

import lombok.*;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

/**
 * @author zhouhengzhe
 * @description: 实体类
 * @date 2022/11/4 10:12
 * @since v1
 */
@Data
@AllArgsConstructor
@Builder
public class Person implements InitializingBean, DisposableBean {
    private String name;
    private Integer age;

    public Person() {
        System.out.println("初始化构造方法");
    }

    /**
     * 会在bean创建完成,并且属性都赋好值以后进行调用
     *
     * @throws Exception
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("属性赋值之后调用");
    }

    /**
     * 会在容器关闭的时候进行调用
     *
     * @throws Exception
     */
    @Override
    public void destroy() throws Exception {
        System.out.println("调用销毁");
    }
}
2.2.3.2.2、创建配置类

然后,在MainConfigByLifeCycle配置类中通过包扫描的方式将以上类注入到Spring容器中。

package com.zhz.config;

import com.zhz.bean.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* 生命周期相关配置
* @author zhouhengzhe
* @date 2022/11/21
*/
@Configuration
    public class MainConfigByLifeCycle {

        @Scope("prototype")
        @Bean
        public Person person(){
            return new Person();
        }
    }

2.2.3.2.3、创建测试类

让我们写一个测试类,代码如下:

@Test
    public void test4ByLiseCycle(){
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfigByLifeCycle.class);
        System.out.println("容器创建完成");
        Person bean = applicationContext.getBean(Person.class);
        applicationContext.close();
    }
2.2.3.2.4、运行结果

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

2.2.3.2.5、总结
  • 在多实例bean情况下,Spring不会自动调用bean的销毁方法

3、指定初始化和销毁方法的使用场景

  • 数据源的管理
  • 线程池的管理

4、初始化和销毁方法调用的时机

  • Bean对象的初始化方法调用的时机:对象创建完成,如果对象中存在一些属性,并且这些属性也都赋好值之后,那么就会调用bean的初始化方法。对于单实例bean来说,在Spring容器创建完成后,Spring容器会自动调用bean的初始化方法;对于多实例bean来说,在每次获取bean对象的时候,调用bean的初始化方法。
  • Bean对象的销毁方法调用的时机:对于单实例bean来说,在容器关闭的时候,会调用bean的销毁方法;对于多实例bean来说,Spring容器不会管理这个bean,也就不会自动调用这个bean的销毁方法了。不过,小伙伴们可以手动调用多实例bean的销毁方法。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/27853.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

(STM32)从零开始的RT-Thread之旅--SPI驱动ST7735(3)使用DMA

上一篇&#xff1a; (STM32)从零开始的RT-Thread之旅--SPI驱动ST7735(2) 上一篇完成了ST7735驱动的移植&#xff0c;并已经可以通过SPI在屏幕上显示字符了&#xff0c;这一章会把SPI修改为DMA的传输方式。由于RTT对于STM32H7的SPI的DMA传输方式目前支持的并不好&#xff0c;这…

Vuex3使用教程(待续)

Vuex定义 以下是Vue官网对于Vuex的定义&#xff1a; Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式 库。它采用集中式存储管理应用的所有组件的状态&#xff0c;并以相应的规则保证状态以一种可预测的方式发生变化。 从官方定义上看&#xff1a; Vuex提供了一个全部组件…

Java注释:单行、多行和文档注释

注释是对程序语言的说明&#xff0c;有助于开发者和用户之间的交流&#xff0c;方便理解程序。注释不是编程语句&#xff0c;因此被编译器忽略。 Java入门基础视频教程&#xff0c;java零基础自学就选黑马程序员Java入门教程&#xff08;含Java项目和Java真题&#xff09; Ja…

【Django】Django4.1.2使用xadmin避坑指南(二)

上一篇【Django】Django4.1.2使用xadmin避坑指南调完后&#xff0c;还是继续有问题&#xff0c;没事&#xff0c;咱们继续&#xff0c;必须啃下硬骨头~ 文章目录环境问题一&#xff1a;if not ContentType._meta.installed:这一句报错&#xff1a;AttributeError: Options obje…

《深度学习进阶 自然语言处理》第八章:Attention介绍

文章目录8.1 Attention结构8.1.1 seq2seq存在的问题8.1.2 编码器的改进8.1.3 解码器的改进8.2 Attention的应用8.3 总结之前文章链接&#xff1a; 开篇介绍&#xff1a;《深度学习进阶 自然语言处理》书籍介绍 第一章&#xff1a;《深度学习进阶 自然语言处理》第一章&#xf…

SSH连接WSL2踩坑记录与增加端口转换规则,实现外网与WSL2的连接

SSH连接WSL2踩坑记录 文章目录SSH连接WSL2踩坑记录1. 在WSL里的操作2. ssh连接3. 可能出现的错误4. 再配置端口转发到WSL1. 在WSL里的操作 1.1 重装openssh-server sudo remove openssh-server # 如果已经安装了&#xff0c;建设先卸载 sudo apt install openssh-server…

Ansys Lumerical | 行波 Mach-Zehnder 调制器仿真分析

前言 本示例描述了行波 Mach-Zehnder 调制器的完整多物理场&#xff08;电气、光学、射频&#xff09;仿真&#xff0c;最后在INTERCONNECT中进行了紧凑模型电路仿真。计算了相对相移、光学传输、传输线带宽和眼图等关键结果。 综述 此示例中5毫米长的Si波导由5毫米长的Al共面…

SpringBoot SpringBoot 开发实用篇 5 整合第三方技术 5.24 SpringBoot 整合 RabbitMQ(topic 模式)

SpringBoot 【黑马程序员SpringBoot2全套视频教程&#xff0c;springboot零基础到项目实战&#xff08;spring boot2完整版&#xff09;】 SpringBoot 开发实用篇 文章目录SpringBootSpringBoot 开发实用篇5 整合第三方技术5.24 SpringBoot 整合 RabbitMQ(topic 模式)5.24.1 …

FL Studio2023水果编曲软件最新版安装教程

FL Studio中文版是知名的音乐制作软件&#xff0c;让你的计算机就像是全功能的录音室&#xff0c;软件包含13种虚拟音源&#xff0c;可同时录制64轨音频轨&#xff0c;FL Studio中文版拥有的漂亮的大混音盘&#xff0c;先进的创作工具&#xff0c;让你的音乐突破想象力的限制&a…

智能化油田建设规划

一、数字化油田-技术现状 数字化油田实现了设备的远程生产过程监控&#xff0c;使井场实现无人值守。所以目前的设备运行维护管理系统只能实现数据统计管理&#xff0c;并不能实现设备状态监控及远程维护及故障诊断。 1、数字化油田— 存在的问题 缺少设备状态在线监测系统&a…

第三章. 业务功能开发--用户登录安全退出

第三章. 业务功能开发--用户登录安全退出 1. 用户登录 需求&#xff1a; 用户在登录页面,输入用户名和密码,点击"登录"按钮或者回车,完成用户登录的功能.*用户名和密码不能为空*用户名或者密码错误,用户已过期,用户状态被锁定,ip受限 都不能登录成功*登录成功之后,所…

Android Jetpack之Lifecycle的使用及源码分析

Lifecycle生命周期感知型组件可执行操作来响应另一个组件&#xff08;如 Activity 和 Fragment&#xff09;的生命周期状态的变化。这些组件有助于您编写出更有条理且往往更精简的代码&#xff0c;此类代码更易于维护。 尤其是在Activity和Fragment在已经默认支持LifeCycle的情…

【第五部分 | JS WebAPI】3:DOM 节点操作

目录 | 节点操作 1-1 概述 2-1 获取父节点 3-1 获取子节点&#xff08;获取所有子对象 不推荐&#xff09; 3-2 获取子节点&#xff08;获取所有子【元素节点】&#xff09; 3-3 获取首尾子节点 4-1 获取兄弟节点 5-1 动态创建、添加节点 5-2 案例&#xff1a;评论区 …

性能测试_JMeter_connection timed out :connect

jmeter报错:failed:connection timed out :connect/java.net.BindException: Address already in use: connect java.net.BindException: Address already in use: connectat java.net.DualStackPlainSocketImpl.connect0(Native Method)at java.net.DualStackPlainSocketImpl…

Linux系统上安装软件

安装jdk&#xff0c;安装tomcat&#xff0c;安装Mysql 四种安装方式&#xff1a; 安装jdk 1.去这个网站上下载linux版本的jdk Java Archive Downloads - Java SE 8 2.在虚拟机中的服务器终端中输入ifconfig&#xff08;注意不是ipconfig&#xff0c;而是ifconfig…

智慧机场解决方案-最新全套文件

智慧机场解决方案-最新全套文件一、建设背景二、建设思路三、建设方案四、获取 - 智慧机场全套最新解决方案合集一、建设背景 中国处在机场持续大规模建设过程中&#xff0c;政府也有意愿建设机场作为城市名片&#xff0c;经济持续增长会带来机场的持续建设&#xff1b;我国机…

螺旋模型的优点与缺点

螺旋模型&#xff1a; 特点&#xff1a; 螺旋模型在“瀑布模型”的每一个开发阶段前引入一个非常严格的风险识别、风险分析和风险控制&#xff0c;它把软件项目分解成一个个小项目。每个小项目都标识一个或多个主要风险&#xff0c;直到所有的主要风险因素都被确定 螺旋模型强…

Copilot:AI自动写代码,人工智能究竟还能取代什么?

Copilot&#xff1a;AI自动写代码&#xff0c;人工智能究竟还能取代什么&#xff1f; 前言 在AI绘画掀起一阵热潮之后&#xff0c;AI写代码又逐渐进入了我们的视野&#xff0c;似乎这一步我们还没想到就迅速到来了&#xff0c;难道说AI在取代画家之后&#xff0c;还要取代程序…

引擎入门 | Unity UI简介–第1部分(7)

本期我们继续为大家进行Unity UI简介&#xff08;第一部分&#xff09;的后续教程 本篇内容 14.放置标题图像 15.添加开始按钮 16.定位按钮 文章末尾可免费获取教程源代码 本篇Unity UI简介&#xff08;第一部分&#xff09;篇幅较长&#xff0c;分为十篇&#xff0c;本篇…

sqli-labs/Less-48

欢迎界面还是以sort为注入参数 接下来进行注入类型的判断 首先输入一下内容 sortrand() 多尝试几次 发现界面会发生变化 所以这一关属于数字型注入 然后我们选择使用报错注入 尝试输入一下内容 sortupdatexml(1,if(11,concat(0x7e,database(),0x7e),1),1)-- 回显如下 呦…