diff --git a/Dockerfile b/Dockerfile index 079acabe..ba53cec7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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 diff --git a/Jenkinsfile b/Jenkinsfile index 96e1e341..d58da0ae 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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 { diff --git a/MIGRATION_NOTES.md b/MIGRATION_NOTES.md new file mode 100644 index 00000000..a76ad58d --- /dev/null +++ b/MIGRATION_NOTES.md @@ -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 `1.8` and `1.8` with `11` +- 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. diff --git a/README.md b/README.md index 2f49958e..6b692cae 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/mvnw b/mvnw old mode 100644 new mode 100755 diff --git a/pom.xml b/pom.xml index fc5bfeac..dac9a1d8 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,9 @@ - 17 + 11 + 11 + UTF-8 @@ -52,8 +54,8 @@ - mysql - mysql-connector-java + com.mysql + mysql-connector-j 8.0.33 runtime @@ -67,6 +69,11 @@ spring-security-test test + + com.h2database + h2 + test + @@ -78,12 +85,41 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + 3.11.0 - 1.8 - 1.8 + 11 + + -Xlint:all + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.2.5 + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.5.0 + + + enforce + + + + [11,) + + + + + + diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties new file mode 100644 index 00000000..3c7cd18a --- /dev/null +++ b/src/test/resources/application.properties @@ -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