代码之家  ›  专栏  ›  技术社区  ›  mcfly soft

application.properties与applicationContext.xml

  •  0
  • mcfly soft  · 技术社区  · 7 年前

    application.properties 文件

    applicationContext.xml 到位了吗?这是用塑料包裹的吗 @SpringBootApplication

    1 回复  |  直到 6 年前
        1
  •  2
  •   Maciej Kowalski    7 年前

    applicationContext.xml 包含bean定义和关系, application.properties 仅用于一般系统配置。

    通常情况下,您会进行基于注释/Java的配置,但如果您碰巧有一些想要使用的遗留beans xml配置,则通常会将其放在以下位置:

    src/main/resources/applicationContext.xml
    

    然后创建具有适当配置注释的类:

    @Configuration
    @ImportResource({"classpath*:applicationContext.xml"})
    public class LegacyXmlConfiguration {}
    

    只需确保该类是要扫描的spring boot包的一部分。