Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Stage 1
#----------------------------------

# Import docker image with maven installed
FROM maven:3.8.3-openjdk-17 as builder
# Import docker image with maven installed (Java 11 for migration)
FROM maven:3.8.8-eclipse-temurin-11 as builder

# Add maintainer, so that new user will understand who had written this Dockerfile
MAINTAINER Madhup Pandey<madhuppandey2908@gmail.com>
Expand All @@ -24,8 +24,8 @@ RUN mvn clean install -DskipTests=true
# Stage 2
#--------------------------------------

# Import small size java image
FROM openjdk:17-alpine as deployer
# Import small size java image (Java 11 for migration)
FROM eclipse-temurin:11-jre-alpine as deployer

# Copy build from stage 1 (builder)
COPY --from=builder /src/target/*.jar /src/target/bankapp.jar
Expand Down
7 changes: 7 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
pipeline {
agent any

tools {
jdk 'JDK11' // Configure JDK 11 in Jenkins Global Tool Configuration
maven 'Maven3' // Ensure Maven 3.x is configured
}

environment{
SONAR_HOME = tool "Sonar"
JAVA_HOME = "${tool 'JDK11'}"
PATH = "${JAVA_HOME}/bin:${env.PATH}"
}

parameters {
Expand Down
80 changes: 80 additions & 0 deletions MIGRATION_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Java 8 to Java 11 Migration Notes

This document summarizes the changes made to migrate the Springboot-BankApp from Java 8 to Java 11.

## Build Configuration Changes

### Maven Compiler Plugin
The maven-compiler-plugin was updated from version 3.8.0 to 3.11.0 with the following configuration changes:

- Replaced `<source>1.8</source>` and `<target>1.8</target>` with `<release>11</release>`
- The `release` flag ensures both source compatibility and bytecode target are set consistently

### Java Version Properties
Updated properties in pom.xml:
- `java.version`: Changed from 17 to 11
- Added `maven.compiler.release`: Set to 11
- Added `project.build.sourceEncoding`: Set to UTF-8

### New Maven Plugins Added
The following plugins were added to ensure Java 11 compatibility and improve build quality:

- **maven-surefire-plugin** (3.2.5): For running unit tests with Java 11 support
- **maven-failsafe-plugin** (3.2.5): For running integration tests
- **maven-enforcer-plugin** (3.5.0): Enforces minimum Java version requirement of 11

## Dependency Updates

### MySQL Connector
Updated the MySQL connector artifact coordinates to the new reverse-DNS compliant Maven 2+ coordinates:
- Old: `mysql:mysql-connector-java:8.0.33`
- New: `com.mysql:mysql-connector-j:8.0.33`

### Test Dependencies
Added H2 database dependency for testing:
- `com.h2database:h2` (test scope)

This allows tests to run without requiring a MySQL database connection.

## Test Configuration

### Test Application Properties
Created `src/test/resources/application.properties` with H2 database configuration for testing:
- Uses in-memory H2 database (`jdbc:h2:mem:testdb`)
- Configured with H2Dialect for Hibernate
- Uses `create-drop` DDL auto mode for clean test isolation

## Removed/Deprecated JDK Modules

No JAXB, JAX-WS, CORBA, or JavaFX dependencies were found in this project. The application does not use any modules that were removed in Java 11.

## Illegal Reflective Access

No illegal reflective access warnings were observed during the build. The application and its dependencies are compatible with Java 11's module system.

## Known Issues and Follow-ups

### JPA Open-in-View Warning
The following warning appears during tests:
```
spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering.
```
This is informational and can be addressed by explicitly setting `spring.jpa.open-in-view=false` in application.properties if desired.

### JVM Sharing Warning
The following warning appears during tests:
```
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
```
This is a normal JVM warning when running with certain class loading configurations and does not affect functionality.

## Validation

- Build passes with `mvn clean verify`
- All tests pass on JDK 11+
- No illegal reflective access warnings
- Maven enforcer plugin ensures Java 11+ is required

## Compatibility

This migration targets Java 11 as the minimum version. The application will also run on later LTS versions (Java 17, Java 21) due to backward compatibility.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
- ArgoCD (CD)
- AWS EKS (Kubernetes)
- Helm (Monitoring using grafana and prometheus)

## Java Requirements

This application requires **Java 11** or later. The build is configured to target Java 11 bytecode and will enforce this minimum version requirement via the Maven Enforcer plugin.

To build and run locally:
```bash
# Verify Java version (must be 11+)
java -version

# Build the application
./mvnw clean package

# Run tests
./mvnw test
```

For detailed migration notes from Java 8 to Java 11, see [MIGRATION_NOTES.md](MIGRATION_NOTES.md).

### Steps to deploy:

Expand Down
Empty file modified mvnw
100644 → 100755
Empty file.
48 changes: 42 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
<url/>
</scm>
<properties>
<java.version>17</java.version>
<java.version>11</java.version>
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
Expand All @@ -52,8 +54,8 @@
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.33</version>
<scope>runtime</scope>
</dependency>
Expand All @@ -67,6 +69,11 @@
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -78,12 +85,41 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>3.11.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>11</release>
<compilerArgs>
<arg>-Xlint:all</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<goals><goal>enforce</goal></goals>
<configuration>
<rules>
<requireJavaVersion>
<version>[11,)</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
12 changes: 12 additions & 0 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
spring.application.name=bankapp

# H2 Database configuration for testing
spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=

# JPA & Hibernate configuration for testing
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.show-sql=true