From edebfa25bb3b62a82bb42da38cd9312a0c794104 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 5 Aug 2026 03:48:45 +0000 Subject: [PATCH] Upgrade from Java 8 to Java 11 (Spring Boot 2.7.18, Gradle 7.6.4) Co-Authored-By: Abhay Aggarwal --- README.md | 4 ++-- build.gradle | 17 ++++++++++------- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 0 mvnw | 0 pom.xml | 6 +++--- src/main/java/hello/Application.java | 18 +++++++++++++----- 7 files changed, 29 insertions(+), 18 deletions(-) mode change 100644 => 100755 gradlew mode change 100644 => 100755 mvnw diff --git a/README.md b/README.md index 2b09400..6605d59 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # springboot-java8 -The project is made on spring boot. The project summarize the new features present in Java 8. +The project is made on spring boot (2.7.x, running on Java 11). The project summarize the new features present in Java 8. It contain list of harcoded topics list. You can call the apis's with POSTMAN to add,delete,update Topic list In addition, it uses 1) Java 8 NIO methods @@ -76,7 +76,7 @@ GET /datetime ### Prerequisites -1) Java sdk +1) Java 11 SDK (JDK 11+) 2) POSTMAN ### Installing diff --git a/build.gradle b/build.gradle index 09f1083..4c17edb 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ buildscript { mavenCentral() } dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.2.RELEASE") + classpath("org.springframework.boot:spring-boot-gradle-plugin:2.7.18") } } @@ -14,19 +14,22 @@ apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' bootJar { - baseName = 'gs-spring-boot' - version = '0.1.0' + archiveBaseName = 'gs-spring-boot' + archiveVersion = '0.1.0' } repositories { mavenCentral() } -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = JavaVersion.VERSION_11 +targetCompatibility = JavaVersion.VERSION_11 dependencies { - compile("org.springframework.boot:spring-boot-starter-web") - testCompile("junit:junit") + implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springframework.boot:spring-boot-starter-jdbc") + runtimeOnly("com.h2database:h2") + runtimeOnly("org.springframework.boot:spring-boot-properties-migrator") + testImplementation("junit:junit") } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a2ff3cc..03a8d13 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/mvnw b/mvnw old mode 100644 new mode 100755 diff --git a/pom.xml b/pom.xml index 63f5cbd..9079e14 100644 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.springframework gs-spring-boot - pom + jar 0.1.0 org.springframework.boot spring-boot-starter-parent - 2.0.2.RELEASE + 2.7.18 @@ -35,7 +35,7 @@ - 1.8 + 11 diff --git a/src/main/java/hello/Application.java b/src/main/java/hello/Application.java index 7cf8faf..b78e39e 100644 --- a/src/main/java/hello/Application.java +++ b/src/main/java/hello/Application.java @@ -36,8 +36,12 @@ public static void main(String[] args) { } RestTemplate restTemplate = new RestTemplate(); - Quote quote = restTemplate.getForObject("http://gturnquist-quoters.cfapps.io/api/random", Quote.class); - log.info(quote.toString()); + try { + Quote quote = restTemplate.getForObject("http://gturnquist-quoters.cfapps.io/api/random", Quote.class); + log.info(quote.toString()); + } catch (Exception e) { + log.warn("Could not fetch quote from remote service: {}", e.getMessage()); + } } @@ -49,9 +53,13 @@ public RestTemplate restTemplate(RestTemplateBuilder builder) { @Bean public CommandLineRunner run(RestTemplate restTemplate) throws Exception { return args -> { - Quote quote = restTemplate.getForObject( - "http://gturnquist-quoters.cfapps.io/api/random", Quote.class); - log.info(quote.toString()); + try { + Quote quote = restTemplate.getForObject( + "http://gturnquist-quoters.cfapps.io/api/random", Quote.class); + log.info(quote.toString()); + } catch (Exception e) { + log.warn("Could not fetch quote from remote service: {}", e.getMessage()); + } }; }