Spring Boot: passing system properties to maven

前端 未结 3 2011
误落风尘
误落风尘 2021-02-15 16:41

I tried:

mvn -Dspring.profiles.active=dev spring-boot:run

but it does not affect my default configuration. I\'ve googled a little and found:

相关标签:
3条回答
  • 2021-02-15 17:26

    Try running your application with:

    mvn spring-boot:run -Drun.jvmArguments="-Dspring.profiles.active=dev"

    I don't know which version your are using but check this issue too

    0 讨论(0)
  • 2021-02-15 17:29

    With the current version (>= 2.0.0.RELEASE), the parameter is -Dspring-boot.run.jvmArguments

    Source: Sprint-boot plugin

    mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dspring.profiles.active=dev"

    It's also possible to do:

    mvn spring-boot:run -Dspring-boot.run.profiles=dev

    0 讨论(0)
  • 2021-02-15 17:38

    I also tried many ways. But in the end, what worked for me was setting them in pom.xml as mentioned in the documentation.

    <project>
      ...
      <build>
        ...
        <plugins>
          ...
          <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.2.2.RELEASE</version>
            <configuration>
                <environmentVariables>
                    <ENV1>5000</ENV1>
                    <ENV2>Some Text</ENV2>
                    <ENV3/>
                    <ENV4></ENV4>
                </environmentVariables>
            </configuration>
            ...
          </plugin>
          ...
        </plugins>
        ...
      </build>
      ...
    </project>
    
    0 讨论(0)
提交回复
热议问题