随笔分类 - spring
摘要:方法一:注解 通过使用注解@Configuration和@Bean来初始化资源,配置文件当然还是通过@Value进行注入。 1)@Configuration:用于定义配置类,可替换xml配置文件,被注解的类内部一般是包含了一个或者多个@Bean注解的方法。2)@Bean:产生一个Bean对象,然后将
阅读全文
摘要:一、注解(annotations)列表 1、@SpringBootApplication 包含了@ComponentScan、@Configuration和@EnableAutoConfiguration注解。其中@ComponentScan让Spring Boot扫描到Configuration类
阅读全文
摘要:spring 中初始化和销毁有三种办法 1、实现接口 DisposableBean ,initilzingBean2、使用注解 @PostConstructor, @PreDestory3、@Bean(initMethod = "",destroyMethod="") package com.sha
阅读全文