Skip to content

Conversation

@yortch
Copy link

@yortch yortch commented Aug 6, 2025

Upgrade Java Project

🖥️ Project Information

  • Project path: c:\Users\jbalderas\source\repos\spring-petclinic-angularjs\spring-petclinic-server
  • Java version: 21
  • Build tool type: Maven
  • Build tool path: C:\Users\jbalderas\apps\apache-maven-3.9.6\bin

🎯 Goals

  • Upgrade Java to 21
  • Upgrade Spring Boot to 3.4.x

🔀 Changes

Test Changes

Total Passed Failed Skipped Errors
Before 3 3 0 0 0
After 3 3 0 0 0

Dependency Changes

Upgraded Dependencies

Dependency Original Version Current Version Module
org.springframework.boot:spring-boot-starter-web 2.1.3.RELEASE 3.4.1 spring-petclinic-server
org.springframework.boot:spring-boot-starter-thymeleaf 2.1.3.RELEASE 3.4.1 spring-petclinic-server
org.springframework.boot:spring-boot-starter-data-jpa 2.1.3.RELEASE 3.4.1 spring-petclinic-server
org.springframework.boot:spring-boot-starter-cache 2.1.3.RELEASE 3.4.1 spring-petclinic-server
org.springframework.boot:spring-boot-starter-actuator 2.1.3.RELEASE 3.4.1 spring-petclinic-server
org.springframework.boot:spring-boot-devtools 2.1.3.RELEASE 3.4.1 spring-petclinic-server
org.springframework.boot:spring-boot-configuration-processor 2.1.3.RELEASE 3.4.1 spring-petclinic-server
org.hsqldb:hsqldb 2.4.1 2.7.3 spring-petclinic-server
org.springframework.boot:spring-boot-starter-test 2.1.3.RELEASE 3.4.1 spring-petclinic-server
javax.cache:cache-api 1.1.0 1.1.1 spring-petclinic-server
org.ehcache:ehcache 3.6.3 3.10.8 spring-petclinic-server
Java 8 21 Root Module

Added Dependencies

Dependency Version Module
jakarta.xml.bind:jakarta.xml.bind-api 4.0.2 spring-petclinic-server
org.springframework.boot:spring-boot-starter-validation 3.4.1 spring-petclinic-server
org.junit.jupiter:junit-jupiter 5.11.4 spring-petclinic-server
com.mysql:mysql-connector-j 9.1.0 spring-petclinic-server
org.glassfish.jaxb:jaxb-runtime 4.0.5 spring-petclinic-server

Removed Dependencies

Dependency Version Module
mysql:mysql-connector-java 8.0.15 spring-petclinic-server

Code commits

25 files changed, 105 insertions(+), 101 deletions(-)

  • 6040910 -- Upgrade Spring Boot from 2.1.3 to 3.3.8 and Java from 8 to 21

  • 90b5da1 -- Add explicit version for jakarta.cache:cache-api dependency

  • 70d558b -- Use correct jakarta.cache:cache-api version 1.1.2

  • 28658b1 -- Revert cache API back to javax.cache as jakarta.cache doesn't exist

  • 17ea34e -- Upgrade Spring Boot from 3.3.8 to 3.4.1 and migrate deprecated test annotations

Potential Issues

Behavior Changes

  • AbstractClinicServiceTests.java
    • [Severity: MINOR] [Confidence: LOW] The method call changed from get(0) to getFirst(). While both should return the first element, getFirst() is a Java 21 method that may have different exception behavior - it throws NoSuchElementException on empty lists while get(0) throws IndexOutOfBoundsException. This could affect test behavior if the list is unexpectedly empty.
    • [Severity: MINOR] [Confidence: LOW] Changed from get(0) to getFirst() method. The getFirst() method is a new Java 21 feature that provides more semantic clarity but functionally equivalent behavior for accessing the first element.
  • PetResourceTests.java
    • [Severity: MINOR] [Confidence: LOW] The expected content type changed from including charset specification to just the media type. This could cause test failures if the actual response includes charset information, as the assertion would no longer match.
    • [Severity: MINOR] [Confidence: LOW] Changed from string literal to MediaType constant. Both represent the same content type, but the constant approach is more maintainable and less error-prone.
  • CacheConfig.java
    • [Severity: MINOR] [Confidence: LOW] The method visibility has been reduced from public to package-private. This could break external code that was accessing this method from outside the package, potentially causing compilation errors or runtime failures in dependent modules.
  • ClinicServiceImpl.java
    • [Severity: MINOR] [Confidence: LOW] Removal of @Autowired annotation from constructor. In Spring Boot 3.x with single constructor, this annotation is optional and the behavior remains functionally equivalent - Spring will still perform dependency injection.
  • OwnerResource.java
    • [Severity: MINOR] [Confidence: LOW] Removal of @Autowired annotation from constructor. In Spring Boot 3.x with single constructor, this annotation is optional and the behavior remains functionally equivalent - Spring will still perform dependency injection.
    • [Severity: MINOR] [Confidence: LOW] Replaced verbose @RequestMapping with more specific @PostMapping. This is functionally equivalent - both map POST requests to the same endpoint with identical behavior.
    • [Severity: MINOR] [Confidence: LOW] Replaced verbose @RequestMapping with @GetMapping and removed explicit parameter name from @PathVariable. Both changes are functionally equivalent - the mapping behavior and parameter binding remain identical.
    • [Severity: MINOR] [Confidence: LOW] Replaced verbose @RequestMapping with @PutMapping and removed explicit parameter name from @PathVariable. Both changes are functionally equivalent - the mapping behavior and parameter binding remain identical.
  • PetResource.java
    • [Severity: MINOR] [Confidence: LOW] Removal of @Autowired annotation from constructor. In Spring Boot 3.x with single constructor, this annotation is optional and the behavior remains functionally equivalent - Spring will still perform dependency injection.
    • [Severity: MINOR] [Confidence: LOW] Removed explicit parameter name from @PathVariable. This is functionally equivalent - Spring will automatically match the parameter name with the path variable name.
    • [Severity: MINOR] [Confidence: LOW] Removed explicit parameter name from @PathVariable. This is functionally equivalent - Spring will automatically match the parameter name with the path variable name.
  • VetResource.java
    • [Severity: MINOR] [Confidence: LOW] Removal of @Autowired annotation from constructor. In Spring Boot 3.x with single constructor, this annotation is optional and the behavior remains functionally equivalent - Spring will still perform dependency injection.
  • VisitResource.java
    • [Severity: MINOR] [Confidence: LOW] Removal of @Autowired annotation from constructor. In Spring Boot 3.x with single constructor, this annotation is optional and the behavior remains functionally equivalent - Spring will still perform dependency injection.
    • [Severity: MINOR] [Confidence: LOW] Removed explicit parameter name from @PathVariable. This is functionally equivalent - Spring will automatically match the parameter name with the path variable name.
    • [Severity: MINOR] [Confidence: LOW] Removed explicit parameter name from @PathVariable. This is functionally equivalent - Spring will automatically match the parameter name with the path variable name.

@yortch yortch marked this pull request as draft August 8, 2025 19:01
Copy link
Member

@arey arey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @yortch for this major upgrade.
Did you test the application? Is everything ok?

<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.2</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: declare version in the <properties> section

@arey arey changed the title Java upgrade Java 21 and Spring Boot 3.4 upgrade Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants