首页 > 其他分享 >Spring: SmartInitializingSingleton

Spring: SmartInitializingSingleton

时间:2023-10-19 12:03:52浏览次数:34  
标签:Spring Component springframework SmartInitializingSingleton org import public


package cn.edu.tju.service3;

import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.stereotype.Component;

@Component
public class MySmartService implements SmartInitializingSingleton {
    @Override
    public void afterSingletonsInstantiated() {
        System.out.println("this is smart: " + this);
    }
}


标签:Spring,Component,springframework,SmartInitializingSingleton,org,import,public
From: https://blog.51cto.com/amadeusliu/7934144

相关文章

  • SpringBoot: 手动注册bean的另一种方法@Import
    packagecn.edu.tju.config;importcn.edu.tju.domain.Car;importorg.springframework.beans.factory.support.BeanDefinitionRegistry;importorg.springframework.beans.factory.support.BeanNameGenerator;importorg.springframework.beans.factory.support.RootBea......
  • Spring:通过@Lazy解决构造方法形式的循环依赖问题
    一、定义2个循环依赖的类packagecn.edu.tju.domain2;importorg.springframework.context.annotation.Lazy;importorg.springframework.stereotype.Component;@ComponentpublicclassA{privatefinalBb;publicBgetB(){returnb;}@......
  • SpringBoot:手动注册bean
    packagecn.edu.tju.config;importcn.edu.tju.domain.Car;importorg.springframework.beans.BeansException;importorg.springframework.beans.factory.config.ConfigurableListableBeanFactory;importorg.springframework.beans.factory.support.BeanDefinitionRegi......
  • SaaS云平台 springboot智慧校园管理平台源码
    智慧校园以互联网为基础,以“大数据+云服务”为核心,融合校园教学、管理、生活软硬件平台,定义智慧校园新生活。智慧校园管理平台管理者、教师、学生、家长提供一站式智慧校园解决方案,实现校园管理智能化.校园生活一体化、校园设施数字化、课堂教学生动化、家校沟通无缝化。系统架构:Ja......
  • 若依springboot 使用MultipartFile 为空
    解决:接口请求参数需要加个入参:@RequestParam("file")代码: postman ......
  • 实现Springboot中MyBatisplus使用分页“@P0”附近有语法错误selectPage, IPage和Page分
    说明:QueryWrapper<Banner> warapper=newQueryWrapper<>();Page<Banner>page=newPage<>(1,1);IPage<Banner>iPage=bannerMapper.selectPage(page,warapper);输出结果还是全部的,没有limit效果。 解决:查了一天发现网上有说,没有进行配置分页插件,加上这个分页插件配置类......
  • [spring-mvc.xml] cannot be opened because it does not exist
    IOExceptionparsingXMLdocumentfromclasspathresource[spring-mvc.xml];nestedexceptionisjava.io.FileNotFoundException:classpathresource[spring-mvc.xml]cannotbeopenedbecauseitdoesnotexist检查pom.xml文件:<packaging>war</packagin......
  • SpringBoot项目中使用mybatis逆向工程
    mybatis逆向工程,即利用现有的数据表结构,生成对应的model实体类、dao层接口,以及对应的mapper.xml映射文件。借助mybatis逆向工程,我们无需手动去创建这些文件。下面是使用Java代码的方式来实现逆向工程,生成文件(也可以使用插件来生成):首先,导入需要的依赖包:mybatis逆向工程的依赖和......
  • Swagger系列:SpringBoot3.x中使用Knife4j
    目录一、简介二、版本说明三、使用四、效果图一、简介官网:https://doc.xiaominfo.com/Knife4j是一个集Swagger2和OpenAPI3为一体的增强解决方案Knife4j是为JavaMVC框架集成Swagger生成Api文档的增强解决方案,前身是swagger-bootstrap-ui,致力于springfox-swagger......
  • Spring源码解析——事务的回滚和提交
    正文上一篇文章讲解了获取事务,并且通过获取的connection设置只读、隔离级别等,这篇文章讲解剩下的事务的回滚和提交。最全面的Java面试网站回滚处理之前已经完成了目标方法运行前的事务准备工作,而这些准备工作最大的目的无非是对于程序没有按照我们期待的那样进行,也就是出现特定......