Springboot項目如何兼容老的Spring項目問題
springboot項目如何兼容老的Spring項目
通過spring boot 啟動類,直接運行報錯
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(DemoApplication.class, args);
MyBean bean = context.getBean(MyBean.class);
System.out.println(bean);
}
}
在啟動類上@ImportResource注解,指定需要加載的xml文件,
@ImportResource(locations = {"classpath:applicationContext.xml"})
此時再運行,就能正常運行了

MyBean
@Getter
@Setter
@ToString
public class MyBean {
private int id;
private String name;
}springboot和spring cloud的兼容關(guān)系

當(dāng)spring cloud 項目啟動報錯
Your project setup is incompatible with our requirements due to following reasons:
Spring Boot [2.4.5] is not compatible with this Spring Cloud release train
便是boot和cloud版本項目不對應(yīng)。
如圖:
ideal會自動提示換什么版本的boot。

總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
使用log4j2自定義配置文件位置和文件名(附log4j2.xml配置實例)
這篇文章主要介紹了使用log4j2自定義配置文件位置和文件名(附log4j2.xml配置實例),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-12-12
Mybatis中特殊SQL的執(zhí)行的實現(xiàn)示例
本文主要介紹了Mybatis中特殊SQL的執(zhí)行的實現(xiàn)示例,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-07-07
使用spring?security?BCryptPasswordEncoder接入系統(tǒng)
這篇文章主要介紹了使用spring?security?BCryptPasswordEncoder接入系統(tǒng)方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-08-08
java中ThreadLocal和ThreadLocalMap淺析
這篇文章主要介紹了java中ThreadLocal和ThreadLocalMap淺析,ThreadLocal類用來設(shè)置線程私有變量?本身不儲存值?主要提供自身引用?和?操作ThreadLocalMap?屬性值得方法,需要的朋友可以參考下2023-09-09
SpringBoot結(jié)合kaptcha生成圖片驗證碼詳解
這篇文章主要為大家詳細介紹了SpringBoot如何結(jié)合kaptcha實現(xiàn)圖片驗證碼功能,文中的示例代碼講解詳細,有需要的小伙伴可以參考一下2024-01-01

