您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關(guān)利用springboot2.x怎么解決Bean對(duì)象注入順序的問題,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。
通過指定接口,重寫指定方法,可以在Bean對(duì)應(yīng)的生命周期方法中執(zhí)行相應(yīng)的程序
本文將分析幾個(gè)Bean對(duì)象,為它們?cè)O(shè)置優(yōu)先級(jí)(通過@Order),然后再打斷點(diǎn)調(diào)試,測試各種生命周期方法的運(yùn)行的順序
在項(xiàng)目當(dāng)中最讓人頭疼的就是bean對(duì)象不被注入的問題,通過本文,你可以很好的解決這個(gè)問題。
先看看本程序使用的依賴
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.0.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.wu</groupId> <artifactId>smartport</artifactId> <version>0.0.1-SNAPSHOT</version> <name>smartport</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <excludes> <exclude> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </exclude> </excludes> </configuration> </plugin> </plugins> </build> </project>
2.1 Order = 1
package com.wu.smartport.controller; import com.wu.smartport.test.User; import org.springframework.beans.BeansException; import org.springframework.beans.factory.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; @Component @Order(1) public class TestController implements BeanNameAware, BeanFactoryAware, ApplicationContextAware, BeanDefinitionRegistryPostProcessor, InitializingBean, DisposableBean { @Autowired private User user; /** * 最先執(zhí)行,需要接口BeanNameAware * * @param name */ @Override public void setBeanName(String name) { // 獲取到的是testController,即注入進(jìn)Spring中的名稱 System.out.println("setBeanName:" + name); } /** * 第2個(gè)執(zhí)行,需要接口BeanFactoryAware * beanFactory可以獲取其他已注入的Bean對(duì)象,但無法注入其他對(duì)象 * * @param beanFactory * @throws BeansException */ @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { } /** * 第3個(gè)執(zhí)行,需要ApplicationContextAware接口 * 可以獲取到上下文對(duì)象applicationContext,允許容器通過應(yīng)用程序上下文環(huán)境創(chuàng)建、獲取、管理bean * * @param applicationContext * @throws BeansException */ @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { // 可以通過上下文對(duì)象獲取工廠并注入對(duì)象 AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory(); } /** * 第4個(gè)執(zhí)行,依賴于InitializingBean接口 * * @throws Exception */ @Override public void afterPropertiesSet() throws Exception { } /** * 第5個(gè)執(zhí)行,依賴于BeanDefinitionRegistryPostProcessor接口 * 當(dāng)完成本方法后,對(duì)象就會(huì)完成注入 * @param registry * @throws BeansException */ @Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { } /** * 第6個(gè)執(zhí)行,來源于BeanFactoryPostProcessor接口,該接口被BeanDefinitionRegistryPostProcessor接口實(shí)現(xiàn)了。 * 一般的Bean對(duì)象在此方法前都被注入到了容器中,如果本對(duì)象沒有獲取到,則可以在這里獲取。 * @param beanFactory * @throws BeansException */ @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { Object user = beanFactory.getBean("user"); } /** * 第7個(gè)執(zhí)行,本方法將被多次執(zhí)行,依賴于BeanPostProcessor接口 * 每注入一個(gè)對(duì)象的時(shí)候,都會(huì)調(diào)用該方法 * @param bean * @param beanName * @return * @throws BeansException */ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { return null; } /** * 第8個(gè)執(zhí)行,本方法將被多次執(zhí)行,依賴于BeanPostProcessor接口 * 每注入一個(gè)對(duì)象之后,都會(huì)調(diào)用該方法 * @param bean * @param beanName * @return * @throws BeansException */ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { return null; } /** * 在本對(duì)象被銷毀后執(zhí)行,依賴于DisposableBean接口 * @throws Exception */ @Override public void destroy() throws Exception { } }
2.2 Order = 15
package com.wu.smartport.test; import org.springframework.beans.BeansException; import org.springframework.beans.factory.*; import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Service; /** * @Author :吳用 * @Date :2021-01-05 8:40 * @Version :1.0 */ @Service @Order(15) public class User implements BeanNameAware, BeanFactoryAware, ApplicationContextAware, BeanDefinitionRegistryPostProcessor, InitializingBean, DisposableBean { @Value("張三") private String name; @Value("12") private int age; public User() { } public User(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } /** * 最先執(zhí)行,需要接口BeanNameAware * * @param name */ @Override public void setBeanName(String name) { System.out.println("setBeanName:" + name); } /** * 第2個(gè)執(zhí)行,需要接口BeanFactoryAware * beanFactory可以獲取其他已注入的Bean對(duì)象,但無法注入其他對(duì)象 * * @param beanFactory * @throws BeansException */ @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { } /** * 第3個(gè)執(zhí)行,需要ApplicationContextAware接口 * 可以獲取到上下文對(duì)象applicationContext,允許容器通過應(yīng)用程序上下文環(huán)境創(chuàng)建、獲取、管理bean * * @param applicationContext * @throws BeansException */ @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { } /** * 第4個(gè)執(zhí)行,依賴于InitializingBean接口 * * @throws Exception */ @Override public void afterPropertiesSet() throws Exception { } /** * 第5個(gè)執(zhí)行,依賴于BeanDefinitionRegistryPostProcessor接口 * 當(dāng)完成本方法后,對(duì)象就會(huì)完成注入 * @param registry * @throws BeansException */ @Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { } /** * 第6個(gè)執(zhí)行,來源于BeanFactoryPostProcessor接口,該接口被BeanDefinitionRegistryPostProcessor接口實(shí)現(xiàn)了。 * 一般的Bean對(duì)象在此方法前都被注入到了容器中,如果本對(duì)象沒有獲取到,則可以在這里獲取。 * @param beanFactory * @throws BeansException */ @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { Object user = beanFactory.getBean("user"); } /** * 第7個(gè)執(zhí)行,本方法將被多次執(zhí)行,依賴于BeanPostProcessor接口 * 每注入一個(gè)對(duì)象的時(shí)候,都會(huì)調(diào)用該方法 * @param bean * @param beanName * @return * @throws BeansException */ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { return null; } /** * 第8個(gè)執(zhí)行,本方法將被多次執(zhí)行,依賴于BeanPostProcessor接口 * 每注入一個(gè)對(duì)象之后,都會(huì)調(diào)用該方法 * @param bean * @param beanName * @return * @throws BeansException */ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { return null; } /** * 在本對(duì)象被銷毀后執(zhí)行,依賴于DisposableBean接口 * @throws Exception */ @Override public void destroy() throws Exception { } }
2.3 Order = 30
package com.wu.smartport.test; import org.springframework.beans.BeansException; import org.springframework.beans.factory.*; import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; /** * @Author :吳用 * @Date :2021-01-05 9:48 * @Version :1.0 */ @Order(30) @Component public class User2 implements BeanNameAware, BeanFactoryAware, ApplicationContextAware, BeanDefinitionRegistryPostProcessor, InitializingBean, DisposableBean { @Value("張三") private String name; @Value("12") private int age; public User2() { } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } /** * 最先執(zhí)行,需要接口BeanNameAware * * @param name */ @Override public void setBeanName(String name) { System.out.println("setBeanName:" + name); } /** * 第2個(gè)執(zhí)行,需要接口BeanFactoryAware * beanFactory可以獲取其他已注入的Bean對(duì)象,但無法注入其他對(duì)象 * * @param beanFactory * @throws BeansException */ @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { } /** * 第3個(gè)執(zhí)行,需要ApplicationContextAware接口 * 可以獲取到上下文對(duì)象applicationContext,允許容器通過應(yīng)用程序上下文環(huán)境創(chuàng)建、獲取、管理bean * * @param applicationContext * @throws BeansException */ @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { } /** * 第4個(gè)執(zhí)行,依賴于InitializingBean接口 * * @throws Exception */ @Override public void afterPropertiesSet() throws Exception { } /** * 第5個(gè)執(zhí)行,依賴于BeanDefinitionRegistryPostProcessor接口 * 當(dāng)完成本方法后,對(duì)象就會(huì)完成注入 * @param registry * @throws BeansException */ @Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { } /** * 第6個(gè)執(zhí)行,來源于BeanFactoryPostProcessor接口,該接口被BeanDefinitionRegistryPostProcessor接口實(shí)現(xiàn)了。 * 一般的Bean對(duì)象在此方法前都被注入到了容器中,如果本對(duì)象沒有獲取到,則可以在這里獲取。 * @param beanFactory * @throws BeansException */ @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { Object user = beanFactory.getBean("user"); } /** * 第7個(gè)執(zhí)行,本方法將被多次執(zhí)行,依賴于BeanPostProcessor接口 * 每注入一個(gè)對(duì)象的時(shí)候,都會(huì)調(diào)用該方法 * @param bean * @param beanName * @return * @throws BeansException */ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { return null; } /** * 第8個(gè)執(zhí)行,本方法將被多次執(zhí)行,依賴于BeanPostProcessor接口 * 每注入一個(gè)對(duì)象之后,都會(huì)調(diào)用該方法 * @param bean * @param beanName * @return * @throws BeansException */ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { return null; } /** * 在本對(duì)象被銷毀后執(zhí)行,依賴于DisposableBean接口 * @throws Exception */ @Override public void destroy() throws Exception { } }
2.4 實(shí)驗(yàn)結(jié)果
如下圖所示
TestController 的Order=1,最高優(yōu)先級(jí)
User 的 Order = 15,中等優(yōu)先級(jí)
User2 的 Order = 30,低優(yōu)先級(jí)
前四個(gè)方法會(huì)按照優(yōu)先級(jí)的順序先后執(zhí)行,然后按優(yōu)先級(jí)順序執(zhí)行postProcessBeanDefinitionRegistry方法,然后再按優(yōu)先級(jí)順序執(zhí)行postProcessBeanFactory方法
postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) 方法很不錯(cuò),給了beanFactory。不僅如此,在此方法以前,所有的Bean對(duì)象已經(jīng)被注入完畢了,所以如果之前你的對(duì)象沒有注入進(jìn)去,你就可以在這里通過beanFactroy獲取對(duì)象,然后把對(duì)象重新注入進(jìn)去。
銷毀的順序
@Dependon 和@Order 共同決定Bean對(duì)象的注入順序,
如果A對(duì)象 @Dependon B對(duì)象,則無論A對(duì)象和B對(duì)象的@Order的值是什么,都以@Dependon標(biāo)簽為主
例如A對(duì)象@Dependon(“b”),@Order(1) ,B對(duì)象@Order(15),則B對(duì)象將先于A對(duì)象注入spring容器中
4.1 一般初始化
根據(jù)上面的實(shí)驗(yàn)我們知道實(shí)現(xiàn)BeanFactoryPostProcessor接口后,重寫void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
在該方法運(yùn)行時(shí),所有的bean對(duì)象都已經(jīng)被注入到了spring容器中,此時(shí)可以利用觀察者模式將你需要初始化的對(duì)象進(jìn)行初始化。
首先,需要寫一個(gè)ObserverForInit接口
package com.wu.smartport.controller; /** * 觀察者,用于初始化 * @Author :吳用 * @Date :2021-01-05 11:02 * @Version :1.0 */ public interface ObserverForInit { /** * 觀察者初始化 */ void observerInit(); }
再讓需要初始化操作的bean對(duì)象實(shí)現(xiàn)該接口
package com.wu.smartport.test; import com.wu.smartport.controller.ObserverForInit; import org.springframework.stereotype.Component; /** * @Author :吳用 * @Date :2021-01-05 11:11 * @Version :1.0 */ @Component public class User implements ObserverForInit { @Override public void observerInit() { System.out.println("我要進(jìn)行初始化了!"); } }
然后再寫一個(gè)管理bean初始化的類 通過遍歷所有的Bean對(duì)象,然后查詢指定的接口或者自定義注解,執(zhí)行相應(yīng)的操作(比如初始化操作。)
package com.wu.smartport.manager; import com.wu.smartport.controller.ObserverForInit; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.stereotype.Component; import java.util.Iterator; /** * @Author :吳用 * @Date :2021-01-05 11:06 * @Version :1.0 */ @Component public class ControllerInitManager implements BeanFactoryPostProcessor { @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { Iterator<String> its = beanFactory.getBeanNamesIterator(); while (its.hasNext()) { String beanName = its.next(); try { Object bean = beanFactory.getBean(beanName); analysisObject(bean); } catch (BeanCreationException e) { } catch (Exception e) { e.printStackTrace(); } } } /** * 分析bean對(duì)象 * * @param bean */ private void analysisObject(Object bean) { analysisInterface(bean); analysisAnnotation(bean); } /** * 分析接口 * * @param bean */ private void analysisInterface(Object bean) { Class<?> beanClass = bean.getClass(); // 分析Interface 和 Annotation Class<?>[] interfaces = beanClass.getInterfaces(); // 分析Class for (Class infs : interfaces) { if (infs.equals(ObserverForInit.class)) { ((ObserverForInit) bean).observerInit(); } } } /** * 分析注解 * * @param bean */ private void analysisAnnotation(Object bean) { } }
4.2 按序初始化
如果對(duì)初始化的順序有自己要求,可以采取如下的方法。至于4.1中的遍歷順序,讀者可以自行研究,但建議自己寫順序,否則一旦springboot框架內(nèi)部有變,咱們程序內(nèi)部的初始順序可能會(huì)出問題。
設(shè)置一個(gè)TreeSet 并給定排序策略,遍歷接口的時(shí)候,先將找到的對(duì)象放入TreeSet中排序,再遍歷完成之后再執(zhí)行相應(yīng)的操作
修改后的接口
package com.wu.smartport.controller; /** * 觀察者,用于初始化 * @Author :吳用 * @Date :2021-01-05 11:02 * @Version :1.0 */ public interface ObserverForInit { /** * 觀察者初始化 */ void observerInit(); /** * 初始化的順序,數(shù)越小,優(yōu)先級(jí)越高 * @return */ int getInitOrder(); }
bean對(duì)象
/** * @Author :吳用 * @Date :2021-01-04 22:51 * @Version :1.0 */ @Component public class PageManager implements ObserverForInit { @Override public void observerInit() { System.out.println("PageManager初始化"); } @Override public int getInitOrder() { return 1000; } }
管理初始化的類
package com.wu.smartport.manager; import com.wu.smartport.controller.ObserverForInit; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.stereotype.Component; import java.util.Comparator; import java.util.Iterator; import java.util.TreeSet; /** * @Author :吳用 * @Date :2021-01-05 11:06 * @Version :1.0 */ @Component public class ControllerInitManager implements BeanFactoryPostProcessor { private TreeSet<ObserverForInit> inits = new TreeSet<>(Comparator.comparingInt(ObserverForInit::getInitOrder)); @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { Iterator<String> its = beanFactory.getBeanNamesIterator(); while (its.hasNext()) { String beanName = its.next(); try { Object bean = beanFactory.getBean(beanName); analysisObject(bean); } catch (BeanCreationException e) { } catch (Exception e) { e.printStackTrace(); } } // 遍歷完成后的操作 analysisByAfterIterator(); } /** * 分析bean對(duì)象 * * @param bean */ private void analysisObject(Object bean) { analysisInterface(bean); analysisAnnotation(bean); } /** * 遍歷之后的操作 */ private void analysisByAfterIterator() { // 按照指定的順序遍歷 // 升序遍歷,order小的先執(zhí)行初始化方法 for (ObserverForInit o : inits) { o.observerInit(); } } /** * 分析接口 * * @param bean */ private void analysisInterface(Object bean) { Class<?> beanClass = bean.getClass(); // 分析Interface 和 Annotation Class<?>[] interfaces = beanClass.getInterfaces(); // 分析Class for (Class infs : interfaces) { if (infs.equals(ObserverForInit.class)) { inits.add((ObserverForInit) bean); } } } /** * 分析注解 * * @param bean */ private void analysisAnnotation(Object bean) { } }
5 基于 Springboot 實(shí)現(xiàn)馮諾依曼結(jié)構(gòu)
下面講解一個(gè)騷操作
馮諾依曼結(jié)構(gòu):將程序和數(shù)據(jù)分別存儲(chǔ)在內(nèi)存當(dāng)中
基于這種思想,我們不光可以把數(shù)據(jù)存儲(chǔ)在容器當(dāng)中,我們還可以把代碼也存儲(chǔ)在springboot容器當(dāng)中。
創(chuàng)建一個(gè)Bean對(duì)象,實(shí)現(xiàn)BeanFactoryPostProcessor接口,在運(yùn)行到該方法的時(shí)候,大部分的對(duì)象已經(jīng)被裝入了spring容器中。你可以在之后必要的地方從spring容器中提取該代碼執(zhí)行。
package com.wu.smartport.test; import com.wu.smartport.SmartportApplication; import javafx.stage.Stage; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import java.io.IOException; import java.util.ArrayList; import java.util.function.Function; import static com.wu.smartport.config.BeanInitOrder.INIT_METHODS; import static com.wu.smartport.config.BeanInitOrder.STAGE_BEAN; /** * @Author :吳用 * @Date :2021-01-05 19:27 * @Version :1.0 */ public class Manager implements BeanFactoryPostProcessor { @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { // 執(zhí)行方法告訴javaFx ArrayList<Function> arr; try{ // 嘗試從容器中獲取代碼塊 Object bean = beanFactory.getBean("function"); arr = (ArrayList<Function>)bean; }catch (Exception e2){ // 如果不存在則創(chuàng)建代碼塊 arr = new ArrayList<>(); } // 書寫一段代碼 Function<Void,Void> f = aVoid -> { // 相關(guān)的業(yè)務(wù) return null; }; arr.add(f); // 將代碼塊注入到spring容器中 DefaultListableBeanFactory factory = (DefaultListableBeanFactory)beanFactory; factory.registerSingleton(INIT_METHODS,arr); } }
在之后一定會(huì)運(yùn)行到的代碼,比如啟動(dòng)類之后,可以執(zhí)行指定的代碼段。
package com.wu.smartport; import javafx.application.Application; import javafx.stage.Stage; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ConfigurableApplicationContext; import java.util.ArrayList; import java.util.function.Function; import static com.wu.smartport.config.BeanInitOrder.INIT_METHODS; import static com.wu.smartport.config.BeanInitOrder.STAGE_BEAN; /** * 主啟動(dòng)類 * @author Wu_Sir */ @SpringBootApplication public class SmartportApplication{ private static volatile ConfigurableApplicationContext run; /** * 主程序入口 * * @param args */ public static void main(String[] args) { run = SpringApplication.run(SmartportApplication.class, args); // 查看是否有要處理的方法 try{ Object bean = beanFactory.getBean("function"); ArrayList<Function> arr = (ArrayList<Function>) bean; for (int i = 0; i < arr.size(); i++) { //如果有,則執(zhí)行該方法。 Function f = arr.get(i); f.apply(null); } }catch (Exception e){ e.printStackTrace(); } } }
看完上述內(nèi)容,你們對(duì)利用springboot2.x怎么解決Bean對(duì)象注入順序的問題有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請(qǐng)關(guān)注億速云行業(yè)資訊頻道,感謝大家的支持。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。