JAVA-24065 Quarkus-vs-SpringBoot: Fixing current codebase (#15949)
This commit is contained in:
parent
c128e0b340
commit
f1105fb6fe
@ -1,16 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>spring-project</artifactId>
|
<artifactId>spring-project</artifactId>
|
||||||
<version>0.1-SNAPSHOT</version>
|
<version>0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>parent-boot-2</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>3.1.3</version>
|
||||||
<relativePath>../../../parent-boot-2</relativePath>
|
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@ -35,14 +34,9 @@
|
|||||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.experimental</groupId>
|
<groupId>io.asyncer</groupId>
|
||||||
<artifactId>spring-native</artifactId>
|
<artifactId>r2dbc-mysql</artifactId>
|
||||||
<version>${spring-native.version}</version>
|
<version>${r2dbc-mysql.version}</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.jasync-sql</groupId>
|
|
||||||
<artifactId>jasync-r2dbc-mysql</artifactId>
|
|
||||||
<version>${jasync-r2dbc-mysql.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@ -84,197 +78,21 @@
|
|||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.graalvm.buildtools</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>native-maven-plugin</artifactId>
|
||||||
<configuration>
|
|
||||||
<classifier>exec</classifier>
|
|
||||||
<layers>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</layers>
|
|
||||||
<image>
|
|
||||||
<builder>paketobuildpacks/builder:tiny</builder>
|
|
||||||
<env>
|
|
||||||
<BP_NATIVE_IMAGE>false</BP_NATIVE_IMAGE>
|
|
||||||
<BPL_JFR_ENABLED>true</BPL_JFR_ENABLED>
|
|
||||||
</env>
|
|
||||||
</image>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<version>3.12.1</version>
|
|
||||||
<configuration>
|
|
||||||
<source>${maven.compiler.release}</source>
|
|
||||||
<target>${maven.compiler.release}</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>spring-release</id>
|
|
||||||
<name>Spring release</name>
|
|
||||||
<url>https://repo.spring.io/release</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>spring-milestone</id>
|
|
||||||
<name>Spring Milestone</name>
|
|
||||||
<url>https://repo.spring.io/milestone</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>spring-snapshot</id>
|
|
||||||
<name>Spring Snapshot</name>
|
|
||||||
<url>https://repo.spring.io/snapshot</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<pluginRepositories>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>spring-milestone</id>
|
|
||||||
<name>Spring milestone</name>
|
|
||||||
<url>https://repo.spring.io/milestone</url>
|
|
||||||
</pluginRepository>
|
|
||||||
</pluginRepositories>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>native</id>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit.platform</groupId>
|
|
||||||
<artifactId>junit-platform-launcher</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<layers>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</layers>
|
|
||||||
<image>
|
|
||||||
<builder>paketobuildpacks/builder:tiny</builder>
|
|
||||||
<env>
|
|
||||||
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
|
|
||||||
<BPL_JFR_ENABLED>true</BPL_JFR_ENABLED>
|
|
||||||
</env>
|
|
||||||
</image>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.experimental</groupId>
|
|
||||||
<artifactId>spring-aot-maven-plugin</artifactId>
|
|
||||||
<version>${spring-native.version}</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>test-generate</id>
|
|
||||||
<goals>
|
|
||||||
<goal>test-generate</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>generate</id>
|
|
||||||
<goals>
|
|
||||||
<goal>generate</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
|
||||||
<id>local-native</id>
|
|
||||||
<properties>
|
|
||||||
<repackage.classifier>exec</repackage.classifier>
|
|
||||||
<native-buildtools.version>${native-buildtools.version}</native-buildtools.version>
|
|
||||||
</properties>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit.platform</groupId>
|
|
||||||
<artifactId>junit-platform-launcher</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.experimental</groupId>
|
|
||||||
<artifactId>spring-aot-maven-plugin</artifactId>
|
|
||||||
<version>${spring-native.version}</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>test-generate</id>
|
|
||||||
<goals>
|
|
||||||
<goal>test-generate</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>generate</id>
|
|
||||||
<goals>
|
|
||||||
<goal>generate</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.graalvm.buildtools</groupId>
|
|
||||||
<artifactId>native-maven-plugin</artifactId>
|
|
||||||
<version>${native-buildtools.version}</version>
|
|
||||||
<extensions>true</extensions>
|
|
||||||
<configuration>
|
|
||||||
<buildArgs combine.children="append">
|
|
||||||
<buildArgs>-H:+AllowVMInspection</buildArgs>
|
|
||||||
</buildArgs>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>build-native</id>
|
|
||||||
<goals>
|
|
||||||
<goal>build</goal>
|
|
||||||
</goals>
|
|
||||||
<phase>package</phase>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>test-native</id>
|
|
||||||
<goals>
|
|
||||||
<goal>test</goal>
|
|
||||||
</goals>
|
|
||||||
<phase>test</phase>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>${maven-surefire-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<argLine>-DspringAot=true
|
|
||||||
-agentlib:native-image-agent=access-filter-file=src/test/resources/access-filter.json,config-merge-dir=target/classes/META-INF/native-image
|
|
||||||
</argLine>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<java.version>17</java.version>
|
||||||
<testcontainers-bom.version>1.17.2</testcontainers-bom.version>
|
<testcontainers-bom.version>1.17.2</testcontainers-bom.version>
|
||||||
<spring-native.version>0.12.1</spring-native.version>
|
<r2dbc-mysql.version>1.0.2</r2dbc-mysql.version>
|
||||||
<maven-surefire-plugin.version>3.1.0</maven-surefire-plugin.version>
|
|
||||||
<native-buildtools.version>0.9.11</native-buildtools.version>
|
|
||||||
<jasync-r2dbc-mysql.version>2.0.8</jasync-r2dbc-mysql.version>
|
|
||||||
<maven.compiler.release>17</maven.compiler.release>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -0,0 +1,2 @@
|
|||||||
|
DROP TABLE IF EXISTS zipcode;
|
||||||
|
CREATE TABLE zipcode (zip VARCHAR(100) PRIMARY KEY, type VARCHAR(255) NULL, city VARCHAR(255) NULL, state VARCHAR(255) NULL, county VARCHAR(255) NULL, timezone VARCHAR(255) NULL);
|
@ -11,16 +11,19 @@ services:
|
|||||||
command: [ 'mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci' ]
|
command: [ 'mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci' ]
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: mysqladmin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
|
test: mysqladmin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
|
||||||
|
volumes:
|
||||||
|
- ./schema.sql:/docker-entrypoint-initdb.d/schema.sql
|
||||||
app:
|
app:
|
||||||
image: docker.io/library/spring-project:0.1-SNAPSHOT
|
image: docker.io/library/spring-project:0.1-SNAPSHOT
|
||||||
network_mode: "host"
|
ports:
|
||||||
environment:
|
- '8080:8080'
|
||||||
DB_URL: r2dbc:mysql://localhost:3306/baeldung?useSSL=true&requireSSL=true
|
environment:
|
||||||
HOST_HOSTNAME: ${EXTERNAL_IP}
|
DB_URL: r2dbc:mysql://db:3306/baeldung?useSSL=true&requireSSL=true
|
||||||
depends_on:
|
HOST_HOSTNAME: ${EXTERNAL_IP}
|
||||||
db:
|
depends_on:
|
||||||
condition: service_healthy
|
db:
|
||||||
deploy:
|
condition: service_healthy
|
||||||
resources:
|
deploy:
|
||||||
limits:
|
resources:
|
||||||
cpus: '3.00'
|
limits:
|
||||||
|
cpus: '3.00'
|
||||||
|
@ -4,36 +4,21 @@ import io.r2dbc.spi.ConnectionFactory;
|
|||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.core.io.ByteArrayResource;
|
|
||||||
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
|
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
|
||||||
import org.springframework.r2dbc.connection.R2dbcTransactionManager;
|
import org.springframework.r2dbc.connection.R2dbcTransactionManager;
|
||||||
import org.springframework.r2dbc.connection.init.ConnectionFactoryInitializer;
|
|
||||||
import org.springframework.r2dbc.connection.init.ResourceDatabasePopulator;
|
|
||||||
import org.springframework.transaction.ReactiveTransactionManager;
|
import org.springframework.transaction.ReactiveTransactionManager;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableR2dbcRepositories
|
@EnableR2dbcRepositories
|
||||||
public class Startup {
|
public class Startup {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(Startup.class, args);
|
SpringApplication.run(Startup.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
ConnectionFactoryInitializer initializer(ConnectionFactory connectionFactory) {
|
public ReactiveTransactionManager transactionManager(ConnectionFactory connectionFactory) {
|
||||||
|
return new R2dbcTransactionManager(connectionFactory);
|
||||||
var initializer = new ConnectionFactoryInitializer();
|
}
|
||||||
initializer.setConnectionFactory(connectionFactory);
|
|
||||||
initializer.setDatabasePopulator(new ResourceDatabasePopulator(new ByteArrayResource((""
|
|
||||||
+ "DROP TABLE IF EXISTS zipcode;"
|
|
||||||
+ "CREATE TABLE zipcode (zip VARCHAR(100) PRIMARY KEY, type VARCHAR(255) NULL, city VARCHAR(255) NULL, state VARCHAR(255) NULL, county VARCHAR(255) NULL, timezone VARCHAR(255) NULL);")
|
|
||||||
.getBytes())));
|
|
||||||
|
|
||||||
return initializer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean ReactiveTransactionManager transactionManager(ConnectionFactory connectionFactory) {
|
|
||||||
return new R2dbcTransactionManager(connectionFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user