启动类中加入
@ImportResource(locations = {"classpath:bean.xml"})
来引入XML文件中配置的bean
在实体类中加入注解
@ConfigurationProperties(prefix = "前缀")
并在application.yml中使用上边注解配置的前缀
本文介绍了如何在Spring启动类中通过`@ImportResource`引入bean.xml配置,并在实体类中使用`@ConfigurationProperties`配合application.yml进行前缀配置。重点讲解了XML与YAML在Spring框架中的整合实践。
启动类中加入
@ImportResource(locations = {"classpath:bean.xml"})
来引入XML文件中配置的bean
在实体类中加入注解
@ConfigurationProperties(prefix = "前缀")
并在application.yml中使用上边注解配置的前缀
2098
1659