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-04
springcloud集成nacos 使用lb 无效问题解决方案
这篇文章主要介绍了解决springcloud集成nacos 使用lb 无效,通过查看spring-cloud-starter-gateway jar中的自动配置类的源码,得知,该jar包中是不支持负载均衡的,需要引入spring-cloud-starter-loadbalancer 来支持,需要的朋友可以参考下2023-04-04


最新评论