spring-boot应用程序.属性maven多模块设置



我正在努力申请。在maven多模块项目中设置属性。我有结构

--parent
----core-api
----infrastructure (infrastructure.properties)
----command
----web (application.properties)

我为应用程序使用了不同的名称。属性,因为我想在目标模块中加载它们。

我读了这个和这个帖子,所以我决定把

@PropertySource(value = { "classpath:application.properties","classpath:infrastructure.properties" })
web模块中的Application.class。但是当我从我的父项目运行命令mvn spring-boot:run时,我得到异常:
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.github.bilak.axonframework.poc.Application]; nested exception is java.io.FileNotFoundException: class path resource [infrastructure.properties] cannot be opened because it does not exist
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:180)

my project可以在这里找到

  1. 我怎么能有这个工作,而使用maven插件?有没有办法在java中设置这个并与maven一起运行?
  2. 这与maven更相关,但我可以运行mvn spring-boot:从web模块运行而不安装依赖模块到本地存储库吗?

Thanks in advance

您可以重用Spring Boot基础设施,而不是自己动手。您可以使用applications-infrastructure.properties并启用infrastructure配置文件。

关于第二个问题,不,你应该先安装其他模块;您还可以在#3436

中找到相关讨论。

最新更新