I have an image of postgres running in the background:
docker run -e POSTGRES_HOST_AUTH_METHOD=md5 -e POSTGRES_PASSWORD=1234 -p 5432:5432 --name CONTAINERNAME -d postgres
I created a database with the name "test-flyway-db", which I can see in pgAdmin
I also have the following pom and plugin set up:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.adamg</groupId>
<artifactId>flyway-test2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>flyway-test2</name>
<description>flyway-test2</description>
<properties>
<flyway.version>4.0.3</flyway.version>
<database.url>jdbc:postgresql://localhost:5432/test-flyway-db</database.url>
<database.user>postgres</database.user>
<database.password>1234</database.password>
<jooq.version>3.16.12</jooq.version>
<flyway.cleanDisabled>false</flyway.cleanDisabled>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jooq</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>10.10.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>10.10.0</version>
<executions>
<execution>
<id>flyway-clean</id>
<phase>process-resources</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>flyway-migrate</id>
<phase>process-resources</phase>
<goals>
<goal>migrate</goal>
</goals>
</execution>
</executions>
<configuration>
<url>${database.url}</url>
<user>${database.user}</user>
<password>${database.password}</password>
<locations>
<location>classpath:db/migration</location>
</locations>
</configuration>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1212</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Lastly, I have the following migration script under "db.migration":
However, when I run "mvn clean install", I get the following error:
Why is it not connecting to the database?