forked from rehmanmuradali/springboot-java8
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Migrate from Java 8 to Java 11 #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
devin-ai-integration
wants to merge
2
commits into
master
Choose a base branch
from
devin/java8-to-11
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main, 'devin/**' ] | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up JDK 11 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '11' | ||
| distribution: 'temurin' | ||
| cache: maven | ||
|
|
||
| - name: Build and verify with Maven | ||
| run: mvn -B clean verify | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # Migration Notes: Java 8 → Java 11 | ||
|
|
||
| ## Java Version Change | ||
|
|
||
| - **Source**: Java 8 (1.8) | ||
| - **Target**: Java 11 | ||
|
|
||
| Java 11 is a Long-Term Support (LTS) release that introduces improvements such as local-variable type inference (`var`), new String methods, HTTP Client API, and enhanced garbage collection. All existing Java 8 features (Streams, Lambdas, NIO, Optional, LocalDateTime) remain fully compatible. | ||
|
|
||
| ## Spring Boot Version Upgrade | ||
|
|
||
| - **From**: Spring Boot 2.0.2.RELEASE | ||
| - **To**: Spring Boot 2.7.18 | ||
|
|
||
| Spring Boot 2.7.x is the final 2.x LTS line and provides full Java 11 support, along with security patches, dependency updates, and improved auto-configuration. | ||
|
|
||
| ## Build Tool Changes | ||
|
|
||
| ### Maven (`pom.xml`) | ||
|
|
||
| - `<java.version>` changed from `1.8` to `11` | ||
| - Added `<maven.compiler.release>11</maven.compiler.release>` | ||
| - Added `<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>` | ||
| - Changed `<packaging>` from `pom` to `jar` | ||
| - Spring Boot parent version updated to `2.7.18` | ||
|
|
||
| ### Gradle (`build.gradle`) | ||
|
|
||
| - `sourceCompatibility` changed from `1.8` to `JavaVersion.VERSION_11` | ||
| - `targetCompatibility` changed from `1.8` to `JavaVersion.VERSION_11` | ||
| - Spring Boot Gradle plugin updated to `2.7.18` | ||
| - Replaced deprecated `compile` configuration with `implementation` | ||
| - Replaced deprecated `testCompile` configuration with `testImplementation` | ||
| - Added `spring-boot-starter-jdbc` and `h2` dependencies to match Maven | ||
|
|
||
| ## Plugin Upgrades | ||
|
|
||
| | Plugin | Version | Purpose | | ||
| |--------|---------|---------| | ||
| | `maven-compiler-plugin` | 3.11.0 | Compiles with `--release 11` flag | | ||
| | `maven-surefire-plugin` | 3.2.5 | Runs unit tests | | ||
| | `maven-failsafe-plugin` | 3.2.5 | Runs integration tests | | ||
| | `maven-enforcer-plugin` | 3.5.0 | Enforces minimum Java 11 at build time | | ||
|
|
||
| ## New Test Coverage | ||
|
|
||
| - **`ApplicationTests.java`**: Spring Boot integration test verifying the application context loads successfully. | ||
| - **`TopicControllerTest.java`**: MockMvc-based tests for all REST endpoints (`GET /topic`, `POST /topic`, `PUT /topic/{id}`, `DELETE /topic/{id}`, `GET /`, `GET /datetime`, etc.). | ||
| - **`TopicServiceTest.java`**: Unit tests for service-layer methods covering Stream operations, NIO file methods, String processing, sorting, and filtering. | ||
|
|
||
| ## CI Workflow Added | ||
|
|
||
| A GitHub Actions CI workflow (`.github/workflows/ci.yml`) was added: | ||
| - Triggers on push and pull request to `main` | ||
| - Uses `actions/setup-java@v4` with Temurin JDK 11 | ||
| - Caches Maven dependencies | ||
| - Runs `mvn -B clean verify` and `mvn -B test` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package hello; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
|
|
||
| @SpringBootTest | ||
| class ApplicationTests { | ||
|
|
||
| @Test | ||
| void contextLoads() { | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 CI workflow ignores the repository's master branch
The new workflow only runs for pushes and pull requests targeting
main, but this repository is checked out withorigin/HEAD -> origin/masterand the base branch ismaster(.git/config:9-11). As a result, PRs into the actual default branch and pushes to it will not trigger this CI workflow, so the newly added Maven verification can be skipped for the mainline branch.Was this helpful? React with 👍 or 👎 to provide feedback.
Debug
Playground