Sharing configuration across modules in Springboot multi-module project

91 views Asked by At

I am setting up a new multi-module Springboot project.

MyApp(root)

  • my-app-commons
  • my-app-api-a

The my-app-commons module will have the model classes and so Application(Main) class isn't required and it can be used as a library (dependency) in other modules.

I intend to connect to GCP bucket from the my-app-api-a module.In future I will have to add more child modules to MyApp. I was thinking if I can have my GCP storage related configuration inside the my-app-commons module and use it as spring managed dependency (autowired) in my-app-api-a module, and possibly in future modules, instead of repeating the configuration related code in multiple modules.

As I am a beginner, I am not sure if its a good approach. I also think I will need Application(Main) class and have component scan to read the configuration.

Please can you suggest the best practice for what I am trying to achieve here.

0

There are 0 answers