当前位置: 首页 > news >正文

做网站租服务器多少钱电脑培训学校哪家最好

做网站租服务器多少钱,电脑培训学校哪家最好,wordpress复古三栏主题,赣州网联科技有限公司在Spring容器加入一个实现了BeanPostProcessor接口bean实例,重写postProcessBeforeInitialization、postProcessAfterInitialization方法,在方法里面写具体的实现,从而达到Spring容器在初如化前或销毁时执行预定的程序,方法如下&a…

在Spring容器加入一个实现了BeanPostProcessor接口bean实例,重写postProcessBeforeInitialization、postProcessAfterInitialization方法,在方法里面写具体的实现,从而达到Spring容器在初如化前或销毁时执行预定的程序,方法如下:

1、pop.xml导包
 

<dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>5.3.37</version>
</dependency>
<dependency>

2、写一个类实现BeanPostProcessor接口,同时写一个User实体类用于测试
实现类:

package test.spring.model;import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;public class LifeBeanAware implements BeanPostProcessor {@Overridepublic Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {// TODO Auto-generated method stubSystem.out.println("前置处理");return null;}@Overridepublic Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {// TODO Auto-generated method stubSystem.out.println("后置处理");return null;}}

User类:

/**
*Description:
*author: ljd
*@date 2024年7月2日 
*@version 1.0 
*/
package test.spring.model;public class User {private int id;private String name;public int getId() {return id;}public void setId(int id) {System.out.println("user赋值");this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public void testPrint() {System.out.println("this is test init function");}@Overridepublic String toString() {return "User [id=" + id + ", name=" + name + "]";}public User() {super();}}

3、applicationContext.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="user1" init-method="testPrint" destroy-method="testPrint" class="test.spring.model.User" ><property name="id" value="1"></property><property name="name" value="zs"></property></bean><bean class="test.spring.model.LifeBeanAware"></bean>
</beans>


4、测试结果

/**
*Description:
*author: ljd
*@date 2024年7月2日 
*@version 1.0 
*/
package testSpring;import org.junit.Test;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;import test.spring.model.User;public class TestSpring {@Testpublic void testUser() {ConfigurableApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");User user=ac.getBean(User.class); System.out.println(user);ac.close();}}

http://www.mmbaike.com/news/27855.html

相关文章:

  • 做网站除了有服务器还需要什么百度开户需要什么条件
  • 在什么网站可以自承包活来做百度手机助手下载安卓版
  • 免费网站建设社区广州市人民政府新闻办公室
  • 网站界面设计工具社群营销
  • flutter 如何做网站网站推广排名优化
  • 网站上的链接怎么做的站长之家最新网站
  • 上海网站设计优刻seo推广排名重要吗
  • 网站建设专业英文百度最新财报
  • 网站建设每天的工作新媒体seo指的是什么
  • 在网站做推广要钱吗长沙百度推广排名优化
  • 潍坊网站建设 管雷鸣宁波网站推广
  • 网页制作与网站建设实战教程视频长沙seo行者seo09
  • 网站开发业务流程谷歌seo排名
  • 医疗机构网站备案seo的工作原理
  • seo优化方式包括长沙seo平台
  • 怎样做网站导航栏有哪些网站可以免费发布广告
  • 木方东莞网站建设技术支持开发网站多少钱
  • 做标准件网站现在做百度快速收录的方法
  • 网站排名易下拉教程营销型网站模板
  • 大连做网站 首选领超科技seo代运营
  • 中小网站推广 一级域名还是二级域名网站怎么弄
  • 广州微信网站建设咨询品牌策划ppt案例
  • 如何使用花生壳做网站如何快速网络推广
  • 做网站有地区差异吗广告联盟平台
  • 手机游戏定制app开发优化关键词首页排行榜
  • 怎样做网站运营线上平台推广方案
  • 天津餐饮网站建设西安今日头条最新新闻
  • 网站制作好以后怎么管理排名优化哪家好
  • 《网站建设 补充合同2023新闻摘抄十条
  • 网站手机版模板免费下载小说关键词自动生成器