Java 9 is about to release soon. Frameworks and tools continue to add support for this new Java 9 release. Spring framework has already provides support for Java 9. In this post, we are going to run Spring projects using Java 9 and Docker.
First of all, we create a new Spring Boot project using Spring Initializr. Here we add only the dependency
Web and use the artifact name
webdemo. Download and extract the created project into the local machine and we are good to go.
We’ll continue to use the Docker image
3.5.0-jdk-9 with JDK 9 build
170 to run this project.
maven_data is the named data container we created to cache downloaded Maven artifacts.
When we run
mvn package in the container, it throws an error.
It turns out that the
2.6 version of Maven Jar Plugin used in the Spring Boot project doesn’t work with Java 9, so we need to upgrade it to
3.0.2 by updating the
Now we can run the
mvn package successfully. Then we start the Spring Boot project using
Now we can navigate to
http://localhost:8080 to see the default error page.
Check out my book Exploring Java 9 for new features in Java 9.