4.3.9 Multiple Configurations for Modules
Why Use Multiple Configurations
In different scenarios, a module’s code may be deployed to different applications but require different configurations.
How to Use
Step 1: When packaging a module’s code for different scenarios, configure different bizName, such as biz1, biz2.
<plugin>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-ark-maven-plugin</artifactId>
<version>${sofa.ark.version}</version>
<executions>
<execution>
<id>default-cli</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- Configure different bizName for different scenarios, such as biz1, biz2 -->
<bizName>biz1</bizName>
<!-- ... Other properties -->
</configuration>
</plugin>
Step 2: In the resources directory of the module, add the following files, where config , biz1 and biz2 are folders:
config/biz1/application.propertiesconfig/biz2/application.propertiesStep 3: Package two differentark-bizfiles with differentbizNamevalues (biz1,biz2):biz1-0.0.1-SNAPSHOT-ark-biz.jarbiz2-0.0.1-SNAPSHOT-ark-biz.jarStep 4: Install the correspondingark-bizmodule for different scenarios. When the module starts, it will read the configuration files based on thebizNamevalue:config/biz1/application.propertiesconfig/biz2/application.properties
Principle
When the module starts, it reads the following files as property sources based on the module name and spring.profiles.active field:
config/${bizName}/application-${profile}.propertiesconfig/${bizName}/application.propertiesIfspring.profiles.activeis not set, it reads the following file as the property source:config/${bizName}/application.properties
Feedback
Was this page helpful?
Welcome propose feedback to community!
Welcome propose feedback to community, or improve this document directly.。
Last modified 2025.25.08: Merge pull request #122 from BetaCat0/doc/vk-proxy (e1ace56)