Spring Into Action With GitHub Code Spaces
Hello friends today we'll learn to use GitHub Code spaces.
Prerequisites:
so let's start with,
What is GitHub Code spaces ?
GitHub Coe spaces provides the pre-configured environment and look & feel like vs code all out of the box in the cloud, imagine like this, if you want to do very small changes & test the code what are the steps you'll have to perform.
And if you miss some configuration, you'll encounter errors.
With GitHub Codespaces, you can avoid these steps and get straight to coding.
Starting with Code Spaces
I assume that you have the GitHub repository.
Click on code & switch to the code spaces tab & click on create code space on main
In very few seconds you'll see something like this in your browser
now let's install all the necessary extensions that we are going to need for our spring boot project. Spring boot Extension Pack
Extension pack for java
Use Spring Initializr to create a simple project
I have additionally added the sayHello() method & annotated the class with @RestController
Let's hit the run & see the results, click on open in browser when your app is up and running
Here it is, your first Spring Boot application running in a Codespace!
Recommended by LinkedIn
Let's Do Some Advance Part
Persisting the configuration
let say you are working in a team, and want to share this amazing feature with your team also, but they'll also need to set up the extensions, & all the things we've just did before start working on the actual implementation part, to simplify this we have devcontainers.
devcontainers manages our all the configurations, so that when anyone create a code space just like we did from the repo they will get all the extensions & every configuration that you do by default. let's configure this.
Click
ctrl + shift + p
Search for codespace
You'll find the first option Add Dev Container Configuration Files.
Select Create new configuration
Search & Select Java or Java & PostgreSQL.
You will see the json like this
You can customize it according to your needs.
For now we will just add some extensions.
Click on extension select Add to devcontainer.json
also add other extensions like this
After adding Extensions our devcontainer.json will look something like this.
now commit the changes & whenever someone opens your repo in codes spaces, they will get all the configuration out of the box, they can just start implementing the task, without worrying about environment & configuration.
I hope this article was helpful for you. If you found it valuable, please share it with your friends and fellow developers. Your support will encourage me to write more articles like this one.
Thank you for reading!
Senior Frontend Engineer | 10+ YOE | React | Next.js | TypeScript | JavaScript | Node.js
10moThat's the way to go. Leveraging Codespaces for Spring Boot development is a game-changer. Streamline your workflow and build those awesome apps effortlessly.