Spring-Boot multi module project load property-file

前端 未结 5 1059
面向向阳花
面向向阳花 2021-02-01 18:21

I have a Spring-Boot-Application as a multimodule-Project in maven. The structure is as follows:

Parent-Project
|--MainApplication
|--Module1
|--ModuleN
<         


        
5条回答
  •  佛祖请我去吃肉
    2021-02-01 18:55

    I had this situation before, I noticed that the properties file was not copied to the jar.

    I made the following to get it working:

    1. In the resources folder, I have created a unique package, then stored my application.properties file inside it. e.g: com/company/project

    2. In the configuration file e.g: TMDBConfig.java I have referenced the full path of my .properties file:

      @Configuration
      @PropertySource("classpath:/com/company/project/application.properties")
      public class AwsConfig
      

    Build and run, it will work like magic.

提交回复
热议问题