Posts

Showing posts with the label Java 11

Java 21 vs. Java 11 - practical comparison

Image
Introduction This study aims to compare some metrics related to Java 11 and Java 21 applications and based on it, approximate the value of savings due to migration. In the tests I used following JDKs: - for Java 11: Coretto openjdk 11.0.19 2023-04-18 LTS - for Java 21: Oracle openjdk 21.0.1 2023-10-17 Hardware: - model: Lenovo Y50-70 - RAM: 16GB DDR3 1600MHz - CPU: Intel Core i7-4720HQ (Quad Core, 2.6GHz - 3.6GHz, 6MB Cache) - OS: Ubuntu Desktop 22.04.3 LTS Application which I've tested is available here Tested aspects Each test was done 10 times, one by one. Collected values description: - application start time – logged in application output: - application initial memory usage – RAM memory usage after application started (by PID from app logs): - application memory usage after init – RAM memory usage after sending request to application endpoint (by PID from app logs): ...

Postgres database connection for Spring app (Java 11)

I’m using Postgres DB in almost all my projects because it’s good enough for most cases and FREE. This article describes how to connect Java&Spring app to a Postgres database. First of all – dependencies: &ltdependencies&gt &ltdependency&gt &ltgroupId&gtorg.postgresql&lt/groupId&gt &ltartifactId&gtpostgresql&lt/artifactId&gt &lt/dependency&gt &ltdependency&gt &ltgroupId&gtorg.springframework.boot&lt/groupId&gt &ltartifactId&gtspring-boot-starter-data-jpa&lt/artifactId&gt &lt/dependency&gt &lt/dependencies&gt Second, add properties. This is short way: spring: datasource: url: jdbc:postgresql://localhost:5432/custom_database username: postgres password: password # if you want your app to auto create tables on start: # jpa: # hibernate: # ...

Keycloak config for Java application with Spring (Java 11)

  If you want to secure your Spring microservice endpoints with Keycloak, you are in perfect place. Let’s do this step by step. First we need is of course to add proper dependencies, I’m using maven: <dependencies> <dependency> <groupId>org.keycloak</groupId> <artifactId>keycloak-spring-boot-starter</artifactId> <version>${keycloak.version}</version> </dependency> <dependency> <groupId>org.keycloak.bom</groupId> <artifactId>keycloak-adapter-bom</artifactId> <version>${keycloak.version}</version> <type>pom</type> </dependency> <dependency> <groupId>org.keycloak</groupId> <artifactId>keycloak-spring-boot-adapter-core</artifactId> <version>${keycloak.version}...