title: Running flyway commands from command line using spring boot properties for maven
body: <p>I have a spring boot project using maven that I've included flyway in:</p>
  <p>pom.xml:</p>
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.flywaydb&lt;/groupId&gt;
          &lt;artifactId&gt;flyway-core&lt;/artifactId&gt;
          &lt;version&gt;6.5.0&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  <p>and application.properties:</p>
  <pre><code>#LOCAL
  spring.datasource.url=jdbc:postgresql://localhost:5432/theDatabase
  spring.datasource.username=theRightUser
  spring.datasource.password=theRightPassword
  </code></pre>
  <p>and it works as expected when I run the application.</p>
  <p>However, I'm trying to run <code>mvn flyway:clean</code> from the command line, and it doesn't seem to recognize the configuration correctly:</p>
  <pre><code>[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:6.4.4:clean (default-cli) on project my-service: org.flywaydb.core.api.FlywayException: Unable to connect to the database. Configure the url, user and password! -&gt; [Help 1]
  </code></pre>
  <p>I tried adding <code>spring.flyway</code> properties (user/pass/url) in the application.properties file but it gave me the same error. What do I need to do to get flyway to read from the application.properies like it does when the application runs normally?</p>
  <hr />
  <p>EDIT: I have made slight progress: I was able to reference my <code>application.properties</code> as a flyway config file by adding this to the pom.xml:</p>
  <pre><code>        &lt;plugin&gt;
              &lt;groupId&gt;org.flywaydb&lt;/groupId&gt;
              &lt;artifactId&gt;flyway-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;6.5.0&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;configFiles&gt;${project.basedir}/src/main/resources/application.properties&lt;/configFiles&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  </code></pre>
  <p>So now in that file, I have <code>flyway.url</code>, <code>flyway.user</code> and <code>flyway.password</code>. This allows me to run flyway goals from the command line, but is not totally the solution I want. I am looking into using this plugin to try and read the properties into the pom.xml file, and then using those values in the <code>flyway-maven-plugin</code>'s <code>&lt;configuration&gt;</code> area.</p>
  <pre><code>        &lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
              &lt;artifactId&gt;properties-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;1.0.0&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;phase&gt;initialize&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;read-project-properties&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;files&gt;
                              &lt;file&gt;${project.basedir}/src/main/resources/application.properties&lt;/file&gt;
                          &lt;/files&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  </code></pre>
  <p>which would allow me to do this:</p>
  <pre><code>        &lt;plugin&gt;
              &lt;groupId&gt;org.flywaydb&lt;/groupId&gt;
              &lt;artifactId&gt;flyway-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;6.5.0&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;url&gt;${spring.datasource.url}&lt;/url&gt;
                  &lt;user&gt;${spring.datasource.username}&lt;/user&gt;
                  &lt;password&gt;${spring.datasource.password}&lt;/password&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  </code></pre>