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的兼容關系
當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版本項目不對應。
如圖:
ideal會自動提示換什么版本的boot。
總結
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Mybatis操作數據時出現:java.sql.SQLSyntaxErrorException:?Unknown?c
這篇文章主要介紹了Mybatis操作數據時出現:java.sql.SQLSyntaxErrorException:?Unknown?column?'XXX'?in?'field?list',需要的朋友可以參考下2023-04-04springcloud集成nacos?使用lb?無效問題解決方案
這篇文章主要介紹了解決springcloud集成nacos?使用lb?無效,通過查看spring-cloud-starter-gateway?jar中的自動配置類的源碼,得知,該jar包中是不支持負載均衡的,需要引入spring-cloud-starter-loadbalancer?來支持,需要的朋友可以參考下2023-04-04springboot如何獲取相對路徑文件夾下靜態(tài)資源的方法
這篇文章主要介紹了springboot如何獲取相對路徑文件夾下靜態(tài)資源的方法,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-05-05