0

I create one project with springboot and in my pom.xml I put some arguments to use when run mvn spring-boot:run just like this:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <arguments>
            <argument>--DATABASE_IP=localhost</argument>
            <argument>--DATABASE_PORT=5432</argument>
            <argument>--DATABASE=rtdpjlite_test</argument>
            <argument>--DATABASE_USERNAME=user</argument>
            <argument>--DATABASE_PASSWORD="</argument>
        </arguments>
        <jvmArguments>
            -Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=512m -XX:PermSize=256m -XX:MaxPermSize=512m         
        </jvmArguments>
    </configuration>
</plugin>

so when I run mvn spring-boot:run he will use this properties in my code, but now I need to run a mvn test, so it's possible to create something like the code above to use when I run the test?

tks

Fabio Ebner
  • 2,613
  • 16
  • 50
  • 77
  • 1
    Any particular reason why you are not using de-facto way of configuring spring boot app using [application.properties](https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html) – sagarr Oct 02 '18 at 16:17

1 Answers1

0

You can use SpringBoot profiles for this and run something like is you want to specify arguments through command line or you can create profile specific properties files and specify the arguments there

mvn spring-boot:run -Dspring.profiles.active=production -Drun.arguments="arg1,arg2"

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-profile-specific-properties

Get command-line arguments from spring-boot:run

Tuhin Kanti Sharma
  • 1,056
  • 2
  • 8
  • 19