0

We are using javalite db migrator maven plugin to manage database migrations in different environments. We do not want to store databse username and password for production environment in properties file. Then how do we supply database username and password from command line while running database migration ?

user34567
  • 258
  • 3
  • 12

1 Answers1

0

After spending few hours and hustling with javalite db-migrator, i figured out that there is no straight forward way to supply database username and passwords from command line. So we figured out this via maven resource filter plugin.

I added maven resource filter plugin, using which i am replacing database username and passwords into db-migrator.properties file. Below is the config of maven resource filter plugin

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <resources>
                        <resource>
                            <directory>src/main/resources</directory>
                            <filtering>true</filtering>
                        </resource>
                    </resources>
                    <overwrite>true</overwrite>
                    <encoding>UTF-8</encoding>
                </configuration>
                <executions>
                    <execution>
                        <id>resource_filter</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Please note that, if you are using spring boot for development then you must add property place holders in @property@ (spring way).

user34567
  • 258
  • 3
  • 12