简体   繁体   中英

Activate Maven Profile from Spring Profile

Suppose I have some Maven profiles and some Spring profiles. I would like to manage all my profiles in an application-(spring-profile).yaml. Is it possible to activate a Maven Profile from a Spring Profile? I read about activating Spring profiles from Maven, but I have not found anything about activating Maven profiles from Spring.

Example

pom.xml

<profiles>
        <profile>
            <id>integration-tests</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                ... (in my case some Postman Collections)
            </build>
        </profile>
</profiles>

manifest-dev.yaml

spring:
   profiles:
      active: integration-tests, other-spring-profile

The Maven profile integration-tests is activated as a Spring profile in the example. I am looking for a preferably declarative way to activate Maven profiles in the application.yaml files

In application.properties set

spring.profile = ${yourActiveSpringProfile}

You can see something around at How to set spring active profiles with maven profiles

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM