Sunday, July 30, 2023

[java] [maven] [dropwizard] DropWizard HelloWorld API from scratch

[0] Preparation.

[1] Make project directory

[2] Create pom file

[3] Create source directory

[4] Complete the pom file

The full pom file would be as follows:

[5] Add Dropwizard files

  • Configuration Class File
  • Application Class File
  • Representation Class File
  • Resource Class File
  • Health Check Class File (optional)
  • Config File

[5.1] Configuration


[5.2] Application


[5.3] Representation


[5.4] Resource


[5.5] HealthCheck


[5.6] Config


[6] Compile and run

Read More

[java] [maven] [dropwizard] Running a Dropwizard application in IntelliJ IDEA, Eclipse and NetBeans


Dropwizard is a framework for building RESTful web services in Java. Similar to Spring Boot, Dropwizard applications are packaged into an executable fat JAR file. In addition to executing a Dropwizard application from the command line, you can increase your productivity by configuring your IDE to do that for you. I’m going to be looking at how to run a Dropwizard application in IntelliJ IDEA, Eclipse and NetBeans.

To execute a Dropwizard application, its main method needs to be called with the correct arguments. When you execute a JAR file from the command line, the JVM reads the entry point to your application from the MANIFEST.MF file. It contains key-value pairs and the key we’re interested in is Main-Class. In a Dropwizard application, this is set to your Applicaiton class.


Read More

[java] [maven] [dropwizard] Dropwizard with JDBI

[0] Preparation.

[1] Clone project

[2] Compile Maven project

Note: you may get error like "Blocked mirror for repositories". This is due to the use of unsecured http. Open pom.xml file and replace "http://" with "https://"

[3] Run migration (h2 database)

Note: you may get error like "Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException". This is due to the JAXB APIs considered to be Java EE APIs and therefore are no longer contained on the default classpath in Java SE 9. In Java 11, they are completely removed from the JDK.

Add the following codes to the dependency section of pom.xml file

[4] Run application

The application will be opened at port 8082 (refer below console output)

Read More

[java] [maven] [dropwizard] [mysql] Dropwizard on host with MySQL on docker

[0] Preparation.

[1] Clone project

[2] Change directory to the project root

[3] Compile Maven project

If you get error invalid target release 11, it could be that your java sdk is not 11. Install JDK 11 first and then set JAVA_HOME path for the JDK 11.

[4] Setup MySQL to run in Docker

Note:you may need to check the name of the container by running docker console command first.

docker ps

[5] Run migration

[6] Run application

[7] Test

[8] Check MySQL Database using container terminal

[9] Check MySQL Database using DBeaver on host

Read More

[java] [maven] [intellij] How to Write Unit Tests in Java

[0] preparation.

[1] Git clone project.

[2] Change directory to the project root.

[3] Open project using IntelliJ IDE.



follow the next steps at


Read More

[docker] [dockerhub] Create a new Docker Image, Run as Container

Start working in a new project directory.

Create demo index.html file.

Create Dockerfile and copy the index.html into the container. (save as .Dockerfile)

Build image.

Run container from image.

Read More

[docker] [dockerhub] Pull Docker Image from Docker Hub and Run it

Pull Image from Docker Hub.

Run the downloaded Docker Image & Access the Application.

Browse the application at http://localhost/hello.

Read More