AVt天堂网 手机版,亚洲va久久久噜噜噜久久4399,天天综合亚洲色在线精品,亚洲一级Av无码毛片久久精品

當前位置:首頁 > 科技  > 軟件

玩轉SpringBoot—自動裝配解決Bean的復雜配置

來源: 責編: 時間:2023-09-28 10:02:38 251觀看
導讀學習目標理解自動裝配的核心原理能手寫一個EnableAutoConfiguration注解理解SPI機制的原理第1章 集成Redis1、引入依賴包<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-s

kc128資訊網——每日最新資訊28at.com

學習目標

  • 理解自動裝配的核心原理
  • 能手寫一個EnableAutoConfiguration注解
  • 理解SPI機制的原理

第1章 集成Redis

1、引入依賴包

<dependency>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-starter-data-redis</artifactId></dependency>

2、配置參數

spring.redis.host=192.168.8.74spring.redis.password=123456spring.redis.database=0

3、controller

package com.example.springbootvipjtdemo.redisdemo;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.data.redis.core.RedisTemplate;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.RestController;/** * @author Eclipse_2019 * @create 2022/6/9 14:36 */@RestController@RequestMapping("/redis")public class RedisController {    @Autowired    private RedisTemplate redisTemplate;    @GetMapping("/save")    public String save(@RequestParam String key,@RequestParam String value){        redisTemplate.opsForValue().set(key,value);        return "添加成功";    }    @GetMapping("/get")    public String get(@RequestParam String key){        String value = (String)redisTemplate.opsForValue().get(key);        return value;    }}

通過上面的案例,我們就能看出來,RedisTemplate這個類的bean對象,我們并沒有通過XML的方式也沒有通過注解的方式注入到IoC容器中去,但是我們就是可以通過@Autowired注解自動從容器里面拿到相應的Bean對象,再去進行屬性注入。kc128資訊網——每日最新資訊28at.com

那這是怎么做到的呢?接下來我們來分析一下自動裝配的原理,等我們弄明白了原理,自然而然你們就懂了RedisTemplate的bean對象怎么來的。kc128資訊網——每日最新資訊28at.com

第2章 自動裝配原理

1、SpringBootApplication注解是入口

@Target(ElementType.TYPE) // 注解的適用范圍,其中TYPE用于描述類、接口(包括包注解類型)或enum聲明@Retention(RetentionPolicy.RUNTIME) // 注解的生命周期,保留到class文件中(三個生命周期)@Documented // 表明這個注解應該被javadoc記錄@Inherited // 子類可以繼承該注解@SpringBootConfiguration // 繼承了Configuration,表示當前是注解類@EnableAutoConfiguration // 開啟springboot的注解功能,springboot的四大神器之一,其借助@import的幫助@ComponentScan(excludeFilters = { // 掃描路徑設置@Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })public @interface SpringBootApplication {...}

在其中比較重要的有三個注解,分別是:kc128資訊網——每日最新資訊28at.com

  • @SpringBootConfiguration:繼承了Configuration,表示當前是注解類。
  • @EnableAutoConfiguration: 開啟springboot的注解功能,springboot的四大神器之一,其借助@import的幫助。
  • @ComponentScan(excludeFilters = { // 掃描路徑設置(具體使用待確認)。

(1)ComponentScan

ComponentScan的功能其實就是自動掃描并加載符合條件的組件(比如@Component和@Repository等)或者bean定義;并將這些bean定義加載到IoC容器中。kc128資訊網——每日最新資訊28at.com

我們可以通過basePackages等屬性來細粒度的定制@ComponentScan自動掃描的范圍,如果不指定,則默認Spring框架實現會從聲明@ComponentScan所在類的package進行掃描。kc128資訊網——每日最新資訊28at.com

注:所以SpringBoot的啟動類最好是放在root package下,因為默認不指定basePackages。kc128資訊網——每日最新資訊28at.com

(2)EnableAutoConfiguration

此注解顧名思義是可以自動配置,所以應該是springboot中最為重要的注解。kc128資訊網——每日最新資訊28at.com

@Target(ElementType.TYPE)@Retention(RetentionPolicy.RUNTIME)@Documented@Inherited@AutoConfigurationPackage@Import(AutoConfigurationImportSelector.class)//【重點注解】public @interface EnableAutoConfiguration {...}

其中最重要的兩個注解:kc128資訊網——每日最新資訊28at.com

  • @AutoConfigurationPackage
  • @Import(AutoConfigurationImportSelector.class)

當然還有其中比較重要的一個類就是:AutoConfigurationImportSelector.class。kc128資訊網——每日最新資訊28at.com

AutoConfigurationPackage

@Target(ElementType.TYPE)@Retention(RetentionPolicy.RUNTIME)@Documented@Inherited@Import(AutoConfigurationPackages.Registrar.class)public @interface AutoConfigurationPackage {}

通過@Import(AutoConfigurationPackages.Registrar.class)kc128資訊網——每日最新資訊28at.com

static class Registrar implements ImportBeanDefinitionRegistrar, DeterminableImports {@Overridepublic void registerBeanDefinitions(AnnotationMetadata metadata,BeanDefinitionRegistry registry) {register(registry, new PackageImport(metadata).getPackageName());}……}

注冊當前啟動類的根package;注冊org.springframework.boot.autoconfigure.AutoConfigurationPackages的BeanDefinition。kc128資訊網——每日最新資訊28at.com

AutoConfigurationPackage注解的作用是將添加該注解的類所在的package作為自動配置package 進行管理。kc128資訊網——每日最新資訊28at.com

可以通過 AutoConfigurationPackages 工具類獲取自動配置package列表。當通過注解@SpringBootApplication標注啟動類時,已經為啟動類添加了@AutoConfigurationPackage注解。路徑為 @SpringBootApplication -> @EnableAutoConfiguration -> @AutoConfigurationPackage。也就是說當SpringBoot應用啟動時默認會將啟動類所在的package作為自動配置的package。kc128資訊網——每日最新資訊28at.com

如我們創建了一個sbia-demo的應用,下面包含一個啟動模塊demo-bootstrap,啟動類時Bootstrap,它添加了@SpringBootApplication注解,我們通過測試用例可以看到自動配置package為com.tm.sbia.demo.boot。kc128資訊網——每日最新資訊28at.com

kc128資訊網——每日最新資訊28at.com

AutoConfigurationImportSelector

kc128資訊網——每日最新資訊28at.com

可以從圖中看出AutoConfigurationImportSelector實現了 DeferredImportSelector 從 ImportSelector繼承的方法:selectImports。kc128資訊網——每日最新資訊28at.com

@Overridepublic String[] selectImports(AnnotationMetadata annotationMetadata) {    if (!isEnabled(annotationMetadata)) {        return NO_IMPORTS;    }    AutoConfigurationMetadata autoConfigurationMetadata = AutoConfigurationMetadataLoader        .loadMetadata(this.beanClassLoader);    AnnotationAttributes attributes = getAttributes(annotationMetadata);    List<String> configurations = getCandidateConfigurations(annotationMetadata,                                                             attributes);    configurations = removeDuplicates(configurations);    Set<String> exclusions = getExclusions(annotationMetadata, attributes);    checkExcludedClasses(configurations, exclusions);    configurations.removeAll(exclusions);    configurations = filter(configurations, autoConfigurationMetadata);    fireAutoConfigurationImportEvents(configurations, exclusions);    return StringUtils.toStringArray(configurations);}

第9行List configurations =getCandidateConfigurations(annotationMetadata,`attributes);其實是去加載各個組件jar下的 public static final String FACTORIES_RESOURCE_LOCATION = "META-INF/spring.factories";外部文件。kc128資訊網——每日最新資訊28at.com

如果獲取到類信息,spring可以通過類加載器將類加載到jvm中,現在我們已經通過spring-boot的starter依賴方式依賴了我們需要的組件,那么這些組件的類信息在select方法中就可以被獲取到。kc128資訊網——每日最新資訊28at.com

protected List<String> getCandidateConfigurations(AnnotationMetadata metadata, AnnotationAttributes attributes) {	List<String> configurations = SpringFactoriesLoader.loadFactoryNames(this.getSpringFactoriesLoaderFactoryClass(), this.getBeanClassLoader());	Assert.notEmpty(configurations, "No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct."); 	return configurations; }

其返回一個自動配置類的類名列表,方法調用了loadFactoryNames方法,查看該方法。kc128資訊網——每日最新資訊28at.com

public static List<String> loadFactoryNames(Class<?> factoryClass, @Nullable ClassLoader classLoader) {	String factoryClassName = factoryClass.getName();	return (List)loadSpringFactories(classLoader).getOrDefault(factoryClassName, Collections.emptyList());}

自動配置器會跟根據傳入的factoryClass.getName()到項目系統路徑下所有的spring.factories文件中找到相應的key,從而加載里面的類。kc128資訊網——每日最新資訊28at.com

這個外部文件,有很多自動配置的類。如下:kc128資訊網——每日最新資訊28at.com

kc128資訊網——每日最新資訊28at.com

其中,最關鍵的要屬@Import(AutoConfigurationImportSelector.class),借助AutoConfigurationImportSelector,@EnableAutoConfiguration可以幫助SpringBoot應用將所有符合條件(spring.factories)的bean定義(如Java Config@Configuration配置)都加載到當前SpringBoot創建并使用的IoC容器。kc128資訊網——每日最新資訊28at.com

(3)SpringFactoriesLoader

其實SpringFactoriesLoader的底層原理就是借鑒于JDK的SPI機制,所以,在將SpringFactoriesLoader之前,我們現在發散一下SPI機制。kc128資訊網——每日最新資訊28at.com

SPI

SPI ,全稱為 Service Provider Interface,是一種服務發現機制。它通過在ClassPath路徑下的META-INF/services文件夾查找文件,自動加載文件里所定義的類。這一機制為很多框架擴展提供了可能,比如在Dubbo、JDBC中都使用到了SPI機制。我們先通過一個很簡單的例子來看下它是怎么用的。kc128資訊網——每日最新資訊28at.com

例子

首先,我們需要定義一個接口,SPIService。kc128資訊網——每日最新資訊28at.com

package com.example.springbootvipjtdemo.spidemo;/** * @author Eclipse_2019 * @create 2022/6/8 17:55 */public interface SPIService {    void doSomething();}

然后,定義兩個實現類,沒別的意思,只輸入一句話。kc128資訊網——每日最新資訊28at.com

package com.example.springbootvipjtdemo.spidemo;/** * @author Eclipse_2019 * @create 2022/6/8 17:56 */public class SpiImpl1 implements SPIService{    @Override    public void doSomething() {        System.out.println("第一個實現類干活。。。");    }}----------------------我是乖巧的分割線----------------------package com.example.springbootvipjtdemo.spidemo;/** * @author Eclipse_2019 * @create 2022/6/8 17:56 */public class SpiImpl2 implements SPIService{    @Override    public void doSomething() {        System.out.println("第二個實現類干活。。。");    }}

最后呢,要在ClassPath路徑下配置添加一個文件。文件名字是接口的全限定類名,內容是實現類的全限定類名,多個實現類用換行符分隔。
文件路徑如下:kc128資訊網——每日最新資訊28at.com

kc128資訊網——每日最新資訊28at.com

內容就是實現類的全限定類名:kc128資訊網——每日最新資訊28at.com

com.example.springbootvipjtdemo.spidemo.SpiImpl1com.example.springbootvipjtdemo.spidemo.SpiImpl2

測試

然后我們就可以通過ServiceLoader.load或者Service.providers方法拿到實現類的實例。其中,Service.providers包位于sun.misc.Service,而ServiceLoader.load包位于java.util.ServiceLoader。kc128資訊網——每日最新資訊28at.com

public class TestSPI {    public static void main(String[] args) {        Iterator<SPIService> providers = Service.providers(SPIService.class);        ServiceLoader<SPIService> load = ServiceLoader.load(SPIService.class);        while(providers.hasNext()) {            SPIService ser = providers.next();            ser.doSomething();        }        System.out.println("--------------------------------");        Iterator<SPIService> iterator = load.iterator();        while(iterator.hasNext()) {            SPIService ser = iterator.next();            ser.doSomething();        }    }}

兩種方式的輸出結果是一致的:kc128資訊網——每日最新資訊28at.com

第一個實現類干活。。。第二個實現類干活。。。--------------------------------第一個實現類干活。。。第二個實現類干活。。。

源碼分析

我們看到一個位于sun.misc包,一個位于java.util包,sun包下的源碼看不到。我們就以ServiceLoader.load為例,通過源碼看看它里面到底怎么做的。kc128資訊網——每日最新資訊28at.com

ServiceLoader

首先,我們先來了解下ServiceLoader,看看它的類結構。kc128資訊網——每日最新資訊28at.com

public final class ServiceLoader<S> implements Iterable<S>//配置文件的路徑private static final String PREFIX = "META-INF/services/";//加載的服務類或接口private final Class<S> service;//已加載的服務類集合private LinkedHashMap<String,S> providers = new LinkedHashMap<>();//類加載器private final ClassLoader loader;//內部類,真正加載服務類private LazyIterator lookupIterator;}

Load

load方法創建了一些屬性,重要的是實例化了內部類,LazyIterator。最后返回ServiceLoader的實例。kc128資訊網——每日最新資訊28at.com

public final class ServiceLoader<S> implements Iterable<S>private ServiceLoader(Class<S> svc, ClassLoader cl) {//要加載的接口service = Objects.requireNonNull(svc, "Service interface cannot be null");//類加載器loader = (cl == null) ? ClassLoader.getSystemClassLoader() : cl;//訪問控制器acc = (System.getSecurityManager() != null) ? AccessController.getContext() : null;//先清空providers.clear();//實例化內部類LazyIterator lookupIterator = new LazyIterator(service, loader);}}

查找實現類

查找實現類和創建實現類的過程,都在LazyIterator完成。當我們調用iterator.hasNext和iterator.next方法的時候,實際上調用的都是LazyIterator的相應方法。kc128資訊網——每日最新資訊28at.com

public Iterator<S> iterator() {return new Iterator<S>() {public boolean hasNext() {return lookupIterator.hasNext();}public S next() {return lookupIterator.next();}.......};}

所以,我們重點關注lookupIterator.hasNext()方法,它最終會調用到hasNextService。kc128資訊網——每日最新資訊28at.com

private class LazyIterator implements Iterator<S>{    Class<S> service;    ClassLoader loader;    Enumeration<URL> configs = null;    Iterator<String> pending = null;    String nextName = null;     private boolean hasNextService() {        //第二次調用的時候,已經解析完成了,直接返回        if (nextName != null) {            return true;        }        if (configs == null) {            //META-INF/services/ 加上接口的全限定類名,就是文件服務類的文件            //META-INF/services/com.viewscenessupervisor.spi.SPIService            String fullName = PREFIX + service.getName();            //將文件路徑轉成URL對象            configs = loader.getResources(fullName);        }        while ((pending == null) || !pending.hasNext()) {            //解析URL文件對象,讀取內容,最后返回            pending = parse(service, configs.nextElement());        }        //拿到第一個實現類的類名        nextName = pending.next();        return true;    }}

創建實例

當然,調用next方法的時候,實際調用到的是,lookupIterator.nextService。它通過反射的方式,創建實現類的實例并返回。kc128資訊網——每日最新資訊28at.com

private class LazyIterator implements Iterator<S>{private S nextService() {//全限定類名String cn = nextName;nextName = null;//創建類的Class對象Class<?> c = Class.forName(cn, false, loader);//通過newInstance實例化S p = service.cast(c.newInstance());//放入集合,返回實例providers.put(cn, p);return p;}}

看到這兒,我想已經很清楚了。獲取到類的實例,我們自然就可以對它為所欲為了!kc128資訊網——每日最新資訊28at.com

JDBC中的應用

我們開頭說,SPI機制為很多框架的擴展提供了可能,其實JDBC就應用到了這一機制。回憶一下JDBC獲取數據庫連接的過程。在早期版本中,需要先設置數據庫驅動的連接,再通過DriverManager.getConnection獲取一個Connection。kc128資訊網——每日最新資訊28at.com

String url = "jdbc:mysql:///consult?serverTimezone=UTC";String user = "root";String password = "root";Class.forName("com.mysql.jdbc.Driver");Connection connection = DriverManager.getConnection(url, user, password);

在較新版本中(具體哪個版本,筆者沒有驗證),設置數據庫驅動連接,這一步驟就不再需要,那么它是怎么分辨是哪種數據庫的呢?答案就在SPI。kc128資訊網——每日最新資訊28at.com

加載

我們把目光回到DriverManager類,它在靜態代碼塊里面做了一件比較重要的事。很明顯,它已經通過SPI機制, 把數據庫驅動連接初始化了。kc128資訊網——每日最新資訊28at.com

public class DriverManager {  static {    loadInitialDrivers();    println("JDBC DriverManager initialized");  }}

具體過程還得看loadInitialDrivers,它在里面查找的是Driver接口的服務類,所以它的文件路徑就是:META-INF/services/java.sql.Driver。kc128資訊網——每日最新資訊28at.com

public class DriverManager {    private static void loadInitialDrivers() {        AccessController.doPrivileged(new PrivilegedAction<Void>() {            public Void run() {                //很明顯,它要加載Driver接口的服務類,Driver接口的包為:java.sql.Driver                //所以它要找的就是META-INF/services/java.sql.Driver文件                ServiceLoader<Driver> loadedDrivers = ServiceLoader.load(Driver.class);                Iterator<Driver> driversIterator = loadedDrivers.iterator();                try{                    //查到之后創建對象                    while(driversIterator.hasNext()) {                        driversIterator.next();                    }                } catch(Throwable t) {                    // Do nothing                }                return null;            }        });    }}

那么,這個文件哪里有呢?我們來看MySQL的jar包,就是這個文件,文件內容為:kc128資訊網——每日最新資訊28at.com

com.mysql.cj.jdbc.Driver。kc128資訊網——每日最新資訊28at.com

kc128資訊網——每日最新資訊28at.com

創建實例

上一步已經找到了MySQL中的com.mysql.jdbc.Driver全限定類名,當調用next方法時,就會創建這個類的實例。它就完成了一件事,向DriverManager注冊自身的實例。kc128資訊網——每日最新資訊28at.com

public class Driver extends NonRegisteringDriver implements java.sql.Driver {    static {        try {            //注冊            //調用DriverManager類的注冊方法            //往registeredDrivers集合中加入實例            java.sql.DriverManager.registerDriver(new Driver());        } catch (SQLException E) {            throw new RuntimeException("Can't register driver!");        }    }    public Driver() throws SQLException {        // Required for Class.forName().newInstance()    }}

創建Connection

在DriverManager.getConnection()方法就是創建連接的地方,它通過循環已注冊的數據庫驅動程序,調用其connect方法,獲取連接并返回。kc128資訊網——每日最新資訊28at.com

private static Connection getConnection(        String url, java.util.Properties info, Class<?> caller) throws SQLException {       //registeredDrivers中就包含com.mysql.cj.jdbc.Driver實例    for(DriverInfo aDriver : registeredDrivers) {        if(isDriverAllowed(aDriver.driver, callerCL)) {            try {                //調用connect方法創建連接                Connection con = aDriver.driver.connect(url, info);                if (con != null) {                    return (con);                }            }catch (SQLException ex) {                if (reason == null) {                    reason = ex;                }            }        } else {            println("    skipping: " + aDriver.getClass().getName());        }    }}

再擴展

既然我們知道JDBC是這樣創建數據庫連接的,我們能不能再擴展一下呢?如果我們自己也創建一個java.sql.Driver文件,自定義實現類MyDriver,那么,在獲取連接的前后就可以動態修改一些信息。kc128資訊網——每日最新資訊28at.com

還是先在項目ClassPath下創建文件,文件內容為自定義驅動類com.viewscenessupervisor.spi.MyDriver我們的MyDriver實現類,繼承自MySQL中的NonRegisteringDriver,還要實現java.sql.Driver接口。這樣,在調用connect方法的時候,就會調用到此類,但實際創建的過程還靠MySQL完成。kc128資訊網——每日最新資訊28at.com

package com.viewscenessupervisor.spipublic class MyDriver extends NonRegisteringDriver implements Driver{    static {        try {            java.sql.DriverManager.registerDriver(new MyDriver());        } catch (SQLException E) {            throw new RuntimeException("Can't register driver!");        }    }    public MyDriver()throws SQLException {}        public Connection connect(String url, Properties info) throws SQLException {        System.out.println("準備創建數據庫連接.url:"+url);        System.out.println("JDBC配置信息:"+info);        info.setProperty("user", "root");        Connection connection =  super.connect(url, info);        System.out.println("數據庫連接創建完成!"+connection.toString());        return connection;    }}--------------------輸出結果---------------------準備創建數據庫連接.url:jdbc:mysql:///consult?serverTimezone=UTCJDBC配置信息:{user=root, password=root}數據庫連接創建完成!com.mysql.cj.jdbc.ConnectionImpl@7cf10a6f

(2)回到SpringFactoriesLoader

借助于Spring框架原有的一個工具類:SpringFactoriesLoader的支持,@EnableAutoConfiguration可以智能的自動配置功效才得以大功告成!kc128資訊網——每日最新資訊28at.com

SpringFactoriesLoader屬于Spring框架私有的一種擴展方案,其主要功能就是從指定的配置文件META-INF/spring.factories加載配置,加載工廠類。kc128資訊網——每日最新資訊28at.com

SpringFactoriesLoader為Spring工廠加載器,該對象提供了loadFactoryNames方法,入參為factoryClass和classLoader即需要傳入工廠類名稱和對應的類加載器,方法會根據指定的classLoader,加載該類加器搜索路徑下的指定文件,即spring.factories文件。kc128資訊網——每日最新資訊28at.com

傳入的工廠類為接口,而文件中對應的類則是接口的實現類,或最終作為實現類。kc128資訊網——每日最新資訊28at.com

public abstract class SpringFactoriesLoader {//...  public static <T> List<T> loadFactories(Class<T> factoryClass, ClassLoader classLoader) {    ...  }        public static List<String> loadFactoryNames(Class<?> factoryClass, ClassLoader classLoader) {    ....  }}

配合@EnableAutoConfiguration使用的話,它更多是提供一種配置查找的功能支持,即根據@EnableAutoConfiguration的完整類名org.springframework.boot.autoconfigure.EnableAutoConfiguration作為查找的Key,獲取對應的一組@Configuration類kc128資訊網——每日最新資訊28at.com

kc128資訊網——每日最新資訊28at.com

上圖就是從SpringBoot的autoconfigure依賴包中的META-INF/spring.factories配置文件中摘錄的一段內容,可以很好地說明問題。kc128資訊網——每日最新資訊28at.com

(重點)所以,@EnableAutoConfiguration自動配置的魔法其實就變成了:kc128資訊網——每日最新資訊28at.com

從classpath中搜尋所有的META-INF/spring.factories配置文件,并將其中
org.springframework.boot.autoconfigure.EnableAutoConfiguration對應的
配置項通過反射(Java Refletion)實例化為對應的標注了@Configuration的JavaConfig形式的IoC容器配置類,然后匯總為一個并加載到IoC容器。kc128資訊網——每日最新資訊28at.com

第3章 補充內容

  • @Target 注解可以用在哪。TYPE表示類型,如類、接口、枚舉@Target(ElementType.TYPE) //接口、類、枚舉@Target(ElementType.FIELD) //字段、枚舉的常量@Target(ElementType.METHOD) //方法@Target(ElementType.PARAMETER) //方法參數@Target(ElementType.CONSTRUCTOR) //構造函數@Target(ElementType.LOCAL_VARIABLE)//局部變量@Target(ElementType.ANNOTATION_TYPE)//注解@Target(ElementType.PACKAGE) ///包
  • @Retention 注解的保留位置。只有RUNTIME類型可以在運行時通過反射獲取其值@Retention(RetentionPolicy.SOURCE) //注解僅存在于源碼中,在class字節碼文件中不包含@Retention(RetentionPolicy.CLASS) // 默認的保留策略,注解會在class字節碼文件中存在,但運行時無法獲得,@Retention(RetentionPolicy.RUNTIME) // 注解會在class字節碼文件中存在,在運行時可以通過反射獲取到
  • @Documented 該注解在生成javadoc文檔時是否保留
  • @Inherited 被注解的元素,是否具有繼承性,如子類可以繼承父類的注解而不必顯式的寫下來。

本文鏈接:http://www.tebozhan.com/showinfo-26-11727-0.html玩轉SpringBoot—自動裝配解決Bean的復雜配置

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。郵件:2376512515@qq.com

上一篇: 阿里云開源通義千問14B模型,CTO周靖人:持續擁抱開源開放

下一篇: @Transactional注解使用以及事務失效的場景

標簽:
  • 熱門焦點
  • 企業采用CRM系統的11個好處

    客戶關系管理(CRM)軟件可以為企業提供很多的好處,從客戶保留到提高生產力。  CRM軟件用于企業收集客戶互動,以改善客戶體驗和滿意度。  CRM軟件市場規模如今超過580
  • Flowable工作流引擎的科普與實踐

    一.引言當我們在日常工作和業務中需要進行各種審批流程時,可能會面臨一系列技術和業務上的挑戰。手動處理這些審批流程可能會導致開發成本的增加以及業務復雜度的上升。在這
  • 微信語音大揭秘:為什么禁止轉發?

    大家好,我是你們的小米。今天,我要和大家聊一個有趣的話題:為什么微信語音不可以轉發?這是一個我們經常在日常使用中遇到的問題,也是一個讓很多人好奇的問題。讓我們一起來揭開這
  • 雅柏威士忌多款單品價格大跌,泥煤頂流也不香了?

    來源 | 烈酒商業觀察編 | 肖海林今年以來,威士忌市場開始出現了降溫跡象,越來越多不斷暴漲的網紅威士忌也開始悄然回歸市場理性。近日,LVMH集團旗下蘇格蘭威士忌品牌雅柏(Ardbeg
  • 小米MIX Fold 3配置細節曝光:搭載領先版驍龍8 Gen2+罕見5倍長焦

    這段時間以來,包括三星、一加、榮耀等等有不少品牌旗下的最新折疊屏旗艦都得到了不少爆料,而小米新一代折疊屏旗艦——小米MIX Fold 3此前也屢屢被傳
  • 2299元起!iQOO Pad明晚首銷:性能最強天璣平板

    5月23日,iQOO如期舉行了新品發布會,除了首發安卓最強旗艦處理器的iQOO Neo8系列新機外,還在發布會上推出了旗下首款平板電腦——iQOO Pad,其最大的賣點
  • OPPO K11評測:旗艦級IMX890加持 2000元檔最強影像手機

    【Techweb評測】中端機型用戶群體巨大,占了中國目前手機市場的大頭,一直以來都是各手機品牌的“必爭之地”,其中OPPO K系列機型一直以來都以高品質、
  • 親歷馬斯克血洗Twitter,硅谷的苦日子在后頭

    文/劉哲銘  編輯/李薇  馬斯克再次揮下裁員大刀。  美國時間11月14日,Twitter約4400名外包員工遭解雇,此次被解雇的員工的主要工作為內容審核等。此前,T
  • 北京:科技教育體驗基地開始登記

      北京“科技館之城”科技教育體驗基地登記和認證工作日前啟動。首批北京科技教育體驗基地擬于2023年全國科普日期間掛牌,后續還將開展常態化登記。  北京科技教育體驗基
Top