i have pom.xml
<?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.4.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>renatius</groupId>
<artifactId>AirLinesSystem</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>AirLinesSystem</name>
<description>AirLinesSystem</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>21</java.version>
<javafx.version>21.0.1</javafx.version>
</properties>
<dependencies>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.3.1.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.3</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>10.20.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.flywaydb/flyway-database-postgresql -->
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-database-postgresql</artifactId>
<version>10.20.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>${javafx.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifest>
<mainClass>renatius.airlinessystem.AirLinesSystemApplication</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>renatius.airlinessystem.AirLinesSystemApplication</mainClass>
<options>
<option>--add-opens=javafx.graphics/javafx.scene=ALL-UNNAMED</option>
<option>--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED</option>
</options>
</configuration>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<mainClass>renatius.airlinessystem.AirLinesSystemApplication</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
</project>
and i have docker-compose.yaml
services:
postgres:
image: 'postgres:13'
container_name: 'AirLinesSystem-postgres'
ports:
- 5438:5432
environment:
- 'POSTGRES_USER=renat_yan'
- 'POSTGRES_DB=java'
- 'POSTGRES_PASSWORD=students'
So when i try to run my Application i am got errors in main method
j
ava.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at [email protected]/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at [email protected]/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1135)
Caused by: org.flywaydb.core.api.FlywayException: No database found to handle jdbc:postgresql://localhost:5438/java
at org.flywaydb.core.internal.jdbc.DriverDataSource.<init>(DriverDataSource.java:158)
at org.flywaydb.core.internal.jdbc.DriverDataSource.<init>(DriverDataSource.java:96)
at org.flywaydb.core.api.configuration.ClassicConfiguration.setDataSource(ClassicConfiguration.java:1547)
at org.flywaydb.core.api.configuration.FluentConfiguration.dataSource(FluentConfiguration.java:635)
at renatius.airlinessystem.AirLinesSystemApplication.main(AirLinesSystemApplication.java:22)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
... 6 more
Exception running application renatius.airlinessystem.AirLinesSystemApplication
public static void main(String[] args) throws ClassNotFoundException {
Flyway flyway = Flyway.configure()
.dataSource("jdbc:postgresql://localhost:5438/java", "renat_yan", "students")
.load();
launch();
}
i tried check my docker container in cmd with command docker ps and got normal answer
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b054b04a58e2 postgres:13 "docker-entrypoint.s…" 10 minutes ago Up 10 minutes 0.0.0.0:5438->5432/tcp AirLinesSystem-postgres
So i dont understand why i am getting this error. i checked java database connection manually and i get right connection. I connected to my db in java. But i need use migration through flyway.
maven-assembly-plugin
withspring-boot-maven-plugin
to properly package the application.