Project setup with SpringBoot, Git and Maven

Tools

The recommended toolchain for this course is:

Resources

These instructions are also available in video format:

Git

Once you have familiarized yourself a bit with Spring, you should set up version control. There are lots of options, but the recommended approach is to use Git and host your project at the DSV Gitea instance.

In order to be able to deploy your code using an external tool like Jenkins, you will need to create a local git repository, add your code to it, and regularly push the updates in your local repository to a server-based mirror that Jenkins can pull the code from.

Setting up gitea remote

In order to set up the remote mirror, start by logging in at Gitea. Once logged in, do the following:

You now have an empty repository prepared on the server, where you will be pushing your code. Under the heading "Clone this repository" you should see the git URL to this repository. In order to minimize authentication-related confusion, you should always be using the "SSH" variant of the git URL.

Keep this page open, you will need the git URL later.

Adding a public key for pushing your code

In order to push code from your computer to the gitea remote, you will need to configure public key authentication for gitea. If you don't already have a public key to use, you will need to create one now:

Now you have a key pair that you can use for pushing your code. You now need to add the public part of that key to your gitea user.

Setting up your local repository and connecting it to the remote

This is how to set up your repository using the command-line git tools:

Your code should now be browseable in the gitea web UI.

The core git commands you will be needing when developing are:

You will need to find out a number of things yourself in order for the group to be able to share a single repository with a reasonable workflow:

Preparing your project for deployment to tomcat

If you usually run your project in SpringBoot's embedded tomcat server, your pom.xml will need to be updated to be buildable by jenkins and produce a deployable artifact.

Now your pom.xml should be all set. The remaining thing to be done is to modify your main application to extend SpringBootServletInitializer:

Once these changes have all been made, commit and push your code to the remote as usual. Once the updates have been pushed to the remote, you should be able to build and deploy yor project using Jenkins.