Fabricio
Fabricio

Reputation: 7925

How to put together two application.yml configs of two projects?

I have two projects. One is just a client¹ that does http request to an external service. The other is a Rest API.

The client¹ reads an url configured in its own application.yml, but when I add a dependency (through pom.xml) to this client in the Rest API project, it no longer reads that property (it is null).

I want it to read from its own application.yml, so that I have a default value (that can be overridden later if necessary). How can I do that?


¹ The client is defined like this:

@Component
@ConfigurationProperties("app.client.notification")
public class NotificationClient { 
    private String url; // comes from application.yml.
                        // Works fine in the client project,
                        // and DOESN'T in the Rest project
}

Upvotes: 0

Views: 164

Answers (1)

rorschach
rorschach

Reputation: 2947

You need to explicitly define the location of that .yml file somewhere in the code a'la @PropertySource("classpath:/application.yml"). I don't know about naming conflicts though, you need to experiment with it yourself.

Upvotes: 1

Related Questions