bilak
bilak

Reputation: 4932

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

Upvotes: 3

Views: 3631

Answers (1)

Stephane Nicoll
Stephane Nicoll

Reputation: 33101

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

Upvotes: 1

Related Questions