简体   繁体   中英

spring-boot application.properties maven multi-module setup

I'm struggling with application.properties setup in maven multimodule project. I have structure

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

I'm using different names for appliaction.properties, because I want to load them all in target module.

I've read this and this posts so I decided to put

@PropertySource(value = { "classpath:application.properties","classpath:infrastructure.properties" })

to my Application.class in web module. But when I run command mvn spring-boot:run from my parent project I get exception:

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 can be found here

  1. How can I have this working while using maven plugin? Is there way to setup this in java and run with maven?
  2. This is more related to maven, but can I run mvn spring-boot:run from web module without installing the dependent modules to local repository?

Thanks in advance

You could reuse Spring Boot infrastructure instead of doing your own thing. You could have applications-infrastructure.properties and enable the infrastructure profile.

Regarding your second question, no you should install the other modules first; you can also find a related discussion in #3436

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM