SpringBoot multi-module uses ConfigurationProperties annotations, why only one module can be used?

  • the current project is divided into multiple sub-modules using maven.
  • each submodule has a corresponding configuration file, which is configured using ConfigurationProperties annotations.

my pom file in the main project looks like this

<dependency>
    <groupId>com.shopping.framework</groupId>
    <artifactId>spring-boot-starter-pay</artifactId>
    <version>1.0.0.RELEASE</version>
</dependency>

<!--  -->
<dependency>
    <groupId>com.shopping.framework</groupId>
    <artifactId>spring-boot-starter-sms</artifactId>
    <version>1.0.0.RELEASE</version>
</dependency>

the problem now is:
the ConfigurationProperties configuration of the spring-boot-starter-pay module takes effect, and the other annotation is invalid. When starting, the breakpoint of the set method will not be entered. If I change the order, it will be the reverse, spring-boot-starter-sms will take effect, and the pay module will not take effect.
excuse me, does ConfigurationProperties only support one class file?

Jul.26,2021

@ Yujiaao is indeed the reason. Thank you very much for your reminder. The final solution is to customize a configuration file for each module, whose name must be different from that of other modules, and then annotate the configuration class to specify the profile name: @ PropertySource ("classpath:sms.properties")

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e597cb-4cc3d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e597cb-4cc3d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?