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。

总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
使用log4j2自定义配置文件位置和文件名(附log4j2.xml配置实例)
这篇文章主要介绍了使用log4j2自定义配置文件位置和文件名(附log4j2.xml配置实例),具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2021-12-12
使用spring security BCryptPasswordEncoder接入系统
这篇文章主要介绍了使用spring security BCryptPasswordEncoder接入系统方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教2023-08-08
java中ThreadLocal和ThreadLocalMap浅析
这篇文章主要介绍了java中ThreadLocal和ThreadLocalMap浅析,ThreadLocal类用来设置线程私有变量 本身不储存值 主要提供自身引用 和 操作ThreadLocalMap 属性值得方法,需要的朋友可以参考下2023-09-09


最新评论