Setup: IDE and New Project

Setup: IDE and New Project

Spring Application Deployed with Kubernetes

Step by step building an application using Spring Boot and deployed via Docker on Kubernetes with Helm

full course
  1. Setup: IDE and New Project
  2. Create the Data Repository
  3. Building a Service Layer
  4. Create a REST Controller
  5. Logging, Tracing and Error Handling
  6. Documentation and Code Coverage
  7. Database as a Service
  8. Containerize the Service With Docker
  9. Docker Registry
  10. Automated Build Pipeline
  11. Helm for Deployment
  12. Setting up a Kubernetes Cluster
  13. Automating Deployment (for CICD)
  14. System Design
  15. Messaging and Event Driven Design
  16. Web UI with React
  17. Containerizing our UI
  18. UI Build Pipeline
  19. Put the UI in to Helm
  20. Creating an Ingress in Kubernetes
  21. Simplify Deployment
  22. Conclusion and Review

 Its very easy to get a spring boot microservice up and running. You can read any variety of articles on medium (or other service) on how to do that. However, there’s little about how to do some of the more complicated things that you need in order to support a deployed application and even fewer that link them all together. This series of articles is intended to draw a clear line between all of the stages in order to help guide you to a deployed application with multiple services.

Setup Your Development Environment

This first article is specifically about setting up a development environment for a service. Although this is generally straightforward, I’m going to cover some tools that make it really easy to initialize an environment from scratch.

Create the Github Repository

We’ll need a version control repository first. Log into your github account and create a new repository. We’re going to make a public repository called medium-customer as a public repository. Initialize the repository with a readme (to give us something to clone) and add a gitignore file configured for java. Clone that repository into your local environment.

Create Your Project Workspace

In the next step we’re going to use spring initializr to initialize our spring boot project. However, before we do that we’re going to make it easy on ourselves by using our intellij plugins to do the heavy lifting. Install the following plugins into intellij (if they’re not installed already):

  • Spring Assistant
  • MapStruct Support
  • Lombok
  • Database Navigator.

Once you have the plugins installed, use File/New Project…to create a new project.

Now setup your maven project

And choose the dependencies in the next screen.

Hopefully, we’ll get a chance to use them all, I’m including some that we might not use directly. The important ones for now are

  • Lombok
  • Spring web
  • H2 database
  • Spring data jpa.

Finish up creating the project. Make sure that the project location points to the directory that we cloned the github repository into.

We also need to include mapstruct, since we’ll be using that for mapping and translating our java beans. Add the following properties and dependencies to your maven pom.xml file

<properties>
   ...
   <org.mapstruct.version>1.3.1.Final</org.mapstruct.version>
</properties>
<dependencies>
   ...
   <dependency>
      <groupId>org.mapstruct</groupId>
      <artifactId>mapstruct</artifactId>
      <version>${org.mapstruct.version}</version>
   </dependency>
   <dependency>
      <groupId>org.mapstruct</groupId>
      <artifactId>mapstruct-processor</artifactId>
      <version>${org.mapstruct.version}</version>
   </dependency>
   ...
</dependencies>

Build and Commit

Now lets make sure that we’ve got something that actually works. Spring initializr gives us some basic project structure and tests, so it will confirm that the compile and spring boot context initialization works.

Run:

maven clean install

You should see a successful build

[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) @ medium-customer ---
[INFO] Building jar: C:\workspace\github\medium-customer\target\medium-customer-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.2.6.RELEASE:repackage (repackage) @ medium-customer ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ medium-customer ---
[INFO] Installing C:\workspace\github\medium-customer\target\medium-customer-0.0.1-SNAPSHOT.jar to C:\Users\brian\.m2\repository\com\brianrook\medium\medium-customer\0.0.1-SNAPSHOT\medium-customer-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\workspace\github\medium-customer\pom.xml to C:\Users\brian\.m2\repository\com\brianrook\medium\medium-customer\0.0.1-SNAPSHOT\medium-customer-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.037 s
[INFO] Finished at: 2020-03-27T15:11:20-06:00
[INFO] ------------------------------------------------------------------------

Now lets commit and push to master for our initial project commit.

git checkout -b initial
git add .
git commit -m "initial commit"
git push
git checkout master
git merge --squash initial
git commit -m "Initial commit"
git push

0 comments on “Setup: IDE and New ProjectAdd yours →

Leave a Reply

Your email address will not be published. Required fields are marked *