From db3ddd2cfc186fabef521441948e380fbe7a3599 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 23 Apr 2026 17:33:44 +0000 Subject: [PATCH] Migrate from Java 6 to Java 11 with Dropwizard 2.1.12 - Upgrade Dropwizard BOM from 1.0.5 to 2.1.12, decoupling project version - Add dropwizard-dependencies BOM import - Add JAXB/Jakarta dependencies managed in dependencyManagement for convergence - Update all Maven plugin versions for Java 11 compatibility - Update maven-compiler-plugin to use release 11 instead of source/target 1.6 - Fix @NotEmpty import: org.hibernate.validator.constraints -> javax.validation.constraints - Fix EmployeeDAO namedQuery typing for Dropwizard 2.x Hibernate API - Migrate test from JUnit 3 to JUnit 5 (Jupiter) - Update example.yml ALPN comment (Java 11 has native ALPN support) - Update README to reflect Dropwizard 2.1.12 and Java 11 requirement - Add module-info.class exclusion in shade plugin filter Co-Authored-By: Wes Convery <2wconvery@gmail.com> --- README.md | 6 +- example.yml | 2 +- pom.xml | 66 +++++++++++++++---- .../employee/EmployeeConfiguration.java | 2 +- .../dropwizard/employee/db/EmployeeDAO.java | 3 +- .../java/com/dropwizard/employee/AppTest.java | 36 ++-------- 6 files changed, 66 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index edb15e8..3aa7b0a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -Employee REST API using Dropwizard 1.0.5 +Employee REST API using Dropwizard 2.1.12 -Java 8 needed to run this code. +Java 11 needed to run this code. Dropwizard is an open source Java framework for developing REST APIs. @@ -35,4 +35,4 @@ To test the example application run the following commands. * To view the list of employees. - http://localhost:8080/employee \ No newline at end of file + http://localhost:8080/employee diff --git a/example.yml b/example.yml index c16c839..4740afe 100644 --- a/example.yml +++ b/example.yml @@ -34,11 +34,11 @@ server: # port: 8443 # keyStorePath: example.keystore # keyStorePassword: example - #this requires the alpn-boot library on the JVM's boot classpath #- type: h2 # port: 8445 # keyStorePath: example.keystore # keyStorePassword: example + # Note: Java 11+ has native ALPN support; no alpn-boot bootclasspath jar is needed. adminConnectors: - type: http port: 8081 diff --git a/pom.xml b/pom.xml index 3688725..be563cc 100644 --- a/pom.xml +++ b/pom.xml @@ -8,15 +8,41 @@ DropwizardEmployee http://maven.apache.org + + 2.1.12 + + io.dropwizard dropwizard-bom - ${project.version} + ${dropwizard.version} pom import + + io.dropwizard + dropwizard-dependencies + ${dropwizard.version} + pom + import + + + jakarta.xml.bind + jakarta.xml.bind-api + 2.3.3 + + + org.glassfish.jaxb + jaxb-runtime + 2.3.3 + + + jakarta.activation + jakarta.activation-api + 1.2.2 + @@ -61,6 +87,18 @@ com.h2database h2 + + jakarta.xml.bind + jakarta.xml.bind-api + + + org.glassfish.jaxb + jaxb-runtime + + + jakarta.activation + jakarta.activation-api + io.dropwizard dropwizard-testing @@ -109,57 +147,57 @@ org.apache.maven.plugins maven-clean-plugin - 2.6.1 + 3.3.1 org.apache.maven.plugins maven-install-plugin - 2.5.2 + 3.1.1 org.apache.maven.plugins maven-surefire-plugin - 2.19.1 + 3.1.2 org.apache.maven.plugins maven-resources-plugin - 2.7 + 3.3.1 org.apache.maven.plugins maven-enforcer-plugin - 1.4.1 + 3.4.1 org.apache.maven.plugins maven-compiler-plugin - 3.6.0 + 3.11.0 org.apache.maven.plugins maven-source-plugin - 2.4 + 3.3.0 org.apache.maven.plugins maven-jar-plugin - 2.6 + 3.3.0 org.apache.maven.plugins maven-shade-plugin - 2.4.3 + 3.5.1 org.apache.maven.plugins maven-deploy-plugin - 2.8.2 + 3.1.1 org.apache.maven.plugins maven-site-plugin - 3.4 + 3.12.1 @@ -216,6 +254,7 @@ META-INF/*.SF META-INF/*.DSA META-INF/*.RSA + module-info.class @@ -239,8 +278,7 @@ org.apache.maven.plugins maven-compiler-plugin - 1.6 - 1.6 + 11 diff --git a/src/main/java/com/dropwizard/employee/EmployeeConfiguration.java b/src/main/java/com/dropwizard/employee/EmployeeConfiguration.java index 9a8e28f..f16b57d 100644 --- a/src/main/java/com/dropwizard/employee/EmployeeConfiguration.java +++ b/src/main/java/com/dropwizard/employee/EmployeeConfiguration.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import io.dropwizard.Configuration; import io.dropwizard.db.DataSourceFactory; -import org.hibernate.validator.constraints.NotEmpty; +import javax.validation.constraints.NotEmpty; import com.dropwizard.employee.core.Template; import javax.validation.Valid; diff --git a/src/main/java/com/dropwizard/employee/db/EmployeeDAO.java b/src/main/java/com/dropwizard/employee/db/EmployeeDAO.java index 203bdc2..8695ca5 100644 --- a/src/main/java/com/dropwizard/employee/db/EmployeeDAO.java +++ b/src/main/java/com/dropwizard/employee/db/EmployeeDAO.java @@ -21,7 +21,8 @@ public Employee create(Employee person) { return persist(person); } + @SuppressWarnings("unchecked") public List findAll() { - return list(namedQuery("com.dropwizard.employee.core.Employee.findAll")); + return list((org.hibernate.query.Query) namedQuery("com.dropwizard.employee.core.Employee.findAll")); } } diff --git a/src/test/java/com/dropwizard/employee/AppTest.java b/src/test/java/com/dropwizard/employee/AppTest.java index ac98328..fef6691 100644 --- a/src/test/java/com/dropwizard/employee/AppTest.java +++ b/src/test/java/com/dropwizard/employee/AppTest.java @@ -1,38 +1,16 @@ package com.dropwizard.employee; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Unit test for simple App. */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } +public class AppTest { - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); + @Test + public void testApp() { + assertTrue(true); } }