From f0934aed3418d9ea3bacdcd342881d578ba15a0c Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 7 Aug 2026 15:49:12 +0000 Subject: [PATCH 1/2] Upgrade to Java 17 LTS and Spring Boot 2.7.18 Co-Authored-By: Toby Drinkall --- .github/workflows/build.yml | 23 ++++++++++++++++++++ .mvn/wrapper/maven-wrapper.properties | 2 +- build.gradle | 26 ++++++++++++++++------- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 0 mvnw | 0 pom.xml | 27 +++++++++++++++++------- src/main/java/hello/Application.java | 18 +++++++++++----- 8 files changed, 75 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/build.yml mode change 100644 => 100755 gradlew mode change 100644 => 100755 mvnw diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..48ada1a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: Build +on: [push, pull_request] +jobs: + maven: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '17' + cache: maven + - run: mvn -B -V clean package + gradle: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '17' + - uses: gradle/actions/setup-gradle@v3 + - run: ./gradlew -V clean bootJar diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index c954cec..3c11064 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1 +1 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip diff --git a/build.gradle b/build.gradle index 09f1083..14bc107 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,8 @@ 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") + classpath("io.spring.gradle:dependency-management-plugin:1.0.15.RELEASE") } } @@ -14,19 +15,28 @@ apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' bootJar { - baseName = 'gs-spring-boot' - version = '0.1.0' + archiveBaseName = 'gs-spring-boot' + version = '0.1.0' } repositories { mavenCentral() } -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } +} -dependencies { - compile("org.springframework.boot:spring-boot-starter-web") - testCompile("junit:junit") +tasks.withType(JavaCompile) { + options.release = 17 } +dependencies { + implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springframework.boot:spring-boot-starter-jdbc") + implementation("javax.annotation:javax.annotation-api:1.3.2") + runtimeOnly("com.h2database:h2") + 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..c805905 100644 --- a/pom.xml +++ b/pom.xml @@ -5,21 +5,16 @@ org.springframework gs-spring-boot - pom + jar 0.1.0 org.springframework.boot spring-boot-starter-parent - 2.0.2.RELEASE + 2.7.18 - - org.springframework.boot - spring-boot-properties-migrator - runtime - org.springframework.boot spring-boot-starter-web @@ -32,15 +27,31 @@ com.h2database h2 + + javax.annotation + javax.annotation-api + 1.3.2 + - 1.8 + 17 + 17 + 3.13.0 + 3.5.6 + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.release} + + org.springframework.boot spring-boot-maven-plugin diff --git a/src/main/java/hello/Application.java b/src/main/java/hello/Application.java index 7cf8faf..bdb2c85 100644 --- a/src/main/java/hello/Application.java +++ b/src/main/java/hello/Application.java @@ -17,11 +17,13 @@ import org.springframework.context.annotation.Bean; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.web.client.RestTemplate; +import org.springframework.web.client.RestClientException; @SpringBootApplication public class Application implements CommandLineRunner { private static final Logger log = LoggerFactory.getLogger(Application.class); + private static final String QUOTERS_URL = "http://gturnquist-quoters.cfapps.io/api/random"; public static void main(String[] args) { @@ -36,8 +38,7 @@ 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()); + logRandomQuote(restTemplate); } @@ -49,12 +50,19 @@ 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()); + logRandomQuote(restTemplate); }; } + private static void logRandomQuote(RestTemplate restTemplate) { + try { + Quote quote = restTemplate.getForObject(QUOTERS_URL, Quote.class); + log.info(quote.toString()); + } catch (RestClientException ex) { + log.warn("Unable to retrieve random quote from {}", QUOTERS_URL, ex); + } + } + @Autowired JdbcTemplate jdbcTemplate; From 892d09b2530d068915f2883e580710eeaa951fce Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 7 Aug 2026 15:52:26 +0000 Subject: [PATCH 2/2] Harden quote startup and modernize Gradle archive version Co-Authored-By: Toby Drinkall --- build.gradle | 2 +- src/main/java/hello/Application.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 14bc107..7bf5992 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ apply plugin: 'io.spring.dependency-management' bootJar { archiveBaseName = 'gs-spring-boot' - version = '0.1.0' + archiveVersion = '0.1.0' } repositories { diff --git a/src/main/java/hello/Application.java b/src/main/java/hello/Application.java index bdb2c85..0c7fb6b 100644 --- a/src/main/java/hello/Application.java +++ b/src/main/java/hello/Application.java @@ -57,7 +57,11 @@ public CommandLineRunner run(RestTemplate restTemplate) throws Exception { private static void logRandomQuote(RestTemplate restTemplate) { try { Quote quote = restTemplate.getForObject(QUOTERS_URL, Quote.class); - log.info(quote.toString()); + if (quote == null) { + log.warn("Unable to retrieve random quote from {}", QUOTERS_URL); + } else { + log.info(quote.toString()); + } } catch (RestClientException ex) { log.warn("Unable to retrieve random quote from {}", QUOTERS_URL, ex); }