【问题标题】:Spring Boot Application with different application.properties具有不同 application.properties 的 Spring Boot 应用程序
【发布时间】:2019-12-26 00:31:47
【问题描述】:

我正在学习 Spring Boot 应用程序,并且在使用 xml 和 java 配置的 Spring 应用程序方面有经验。

我正在使用的应用程序具有包含 UI、服务和 DAO 的代码库架构。 所有这些组件都有单独的上下文文件,即。 web-applicationcontext.xml 或 application-servlet-context.xml、service-context.xml 和 data-context.xml 这些文件中的每一个都将具有该层的单独上下文配置,即。在 data-context.xml 中,将添加数据库配置,在 ui-context.xml 中将添加调度程序 serverlet 和 mvc 组件。此外,Web 上下文配置将放置在 UI 项目中,而数据库上下文配置将放置在数据库 maven 项目中。编译时dao项目会被编译并包含在服务项目中,服务项目会被包含在UI项目中。在上下文加载期间,所有上下文文件都将位于类路径中,因此将加载所有 bean。

现在我必须为 Spring Boot 应用程序提供类似的代码库和配置。在 Spring Boot 中可以吗?

【问题讨论】:

    标签: spring spring-boot


    【解决方案1】:

    在 Spring Boot 中,您可以定义不同的配置文件来管理不同的配置。 https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html

    此外,@ConditionalOn* 注释可以帮助您灵活配置。 https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-auto-configuration.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-10
      • 1970-01-01
      • 2019-02-01
      • 2018-02-19
      • 2020-03-29
      • 2018-05-07
      • 2020-02-07
      • 2019-07-25
      相关资源
      最近更新 更多