GIT – The home for source code… #2

Welcome Back!

In the last blog, we saw how to install GIT and get started with it. Here, we will be covering few basic concepts of git, git commands, etc.

What will be covered in this part #2

  1. What is a repository?
  2. How to create a new repository or use an existing one?
  3. How to check the status of the repository?
  4. ….& many more

What is a repository?

A repository is a virtual area where GIT stores the codes and maintain the versions. This can be also thought of as the workplace for GIT. We can create our own repository or clone an existing repository as well.

Initialize a repository in local…

  • To initialize a repository i.e. to create a new repository we will use the “ git initcommand. This is one of the first steps to execute while using GIT.
  • This is a one time command used to create a repository which will create a “ .git directory in the working directory. This contains all the metadata required for git.
  • For the existing project, to make that a GIT repo, navigate to that directory and execute the GIT init command. This will make the working project directory a GIT repository.
  • The .git folder contains much information such as the current HEAD (currently checked out commits), Objects, etc.

Clone a repository to local…

  • To get an existing project from GIT repository to local is known as Cloning a GIT Repository.
  • This syncs all the files on the remote repository (coming next) to a local repository and then we can add and edit files and then push it to the remote repository.
  • $git clone
  • Once this is successful, subfolders would be created under local repository directory and all the files would be cloned into it.
  • This clone contains files, folders, metadata that GIT requires to maintain the changes made on the repository.

We have seen the two ways have the git workplace ready for use. But will start over again with initializing a new repository and take a deep dive into it.

Continue reading


GIT – The home for source code…

This article is about the source code versioning tool GIT. It became a direct choice for most of the projects for its ease is using and it is also reliable and faster than its counterpart present in the market. Please begin with some fundamental concepts related to GIT…

What is version control system?

We must have kept versions of our code by one mean or other by keeping the backup of the file, sending in emails so we can get it back later (Be careful! Companies keep an eye on that… 😛 😛 ). Version control systems are technologies rather tools that keep an eye and track the changes we do in our code throughout the lifetime of the project or the products. Editing anything in our codebase asks VCS to save the snapshot permanently which can be fetched later as we need.

What are some of the benefits of version control system…

  • Workflows
  • Versions
  • Developers
  • Histories
  • Automation

Continue reading

Enable JPA Tools in Eclispe

Hello Guys..

Sometime we need to generate entities from the database table or vice versa. Off course we can do it manually, but that is huge time consuming process.

In those situations, JPA Tools comes into action and plays a handy role creating the entities from already existing the database. How can we do that in our project.

  1. Convert the project into JPA Project. (Right click on project -> configurations -> convert to JPA Project)
  2. Once converted, again right click on the same project and you will see a “JPA TOOLS” in the context menu options.
  3. There you will see “Generate tables from entities” and few more options.

Now if you are using STS, you will wonder why you can not convert the given project to JPA project. In fact the option in configuration is missing itself. Then how can we convert the project??

Continue reading

Java Eclipse/STS Tips | Disable formatting for specific section

Sometimes which is a necessary and we get habituated off using that more often then not may cause an undesirable effect. Confused?

Let me give you an example of how a frequently used practise possess issues.
Consider “formatting” (CTRL + SHIFT + F), this has been one of the favourite combination for all eclipse users .

If you are a java or spring developer, then you might have figured it out… right ?

No? No issues .. In Java when we use streams and we intentionally break steps  of the chain logically. But if we intended Eclipse to format all the codes in that .java file, it do not understands our logical breaking and brings everything to one line. Also Spring developers might have faced it during Security Configurations with HTTP chaining.

Before formatting

List persons = new ArrayList();
String name =
		.filter(x -> "sovan".equals(x.toString()))

After formatting

List persons = new ArrayList();
String name = -> "sovan".equals(x.toString())).map(String::toLowerCase).findAny()

Is there a way we can stop formatting for this section of code?


This feature is there only inside our developer tool.. Hidden secret!! HUH!!
Now let this secret revealed..

  • Go to Windows -> Preferences -> Java -> Code Styling -> “Formatter”
  • Click on Edit on the details section. (You can create your own development profile)
  • In the edit section, choose “On/Off tags”.
  • Check “Enable Off/On Tags”. Leave the default @formatteroff and @formatteron or you can rename the tags.
  • Done. Save your profile.

    This slideshow requires JavaScript.

Now wrap your codes around these off and on tag and eclipse will leave that section  untouched while formatting rest of the code.

If you like this post and is helpful, please do leave a comment below. If anyone knows any other better way of doing this, please do share.

Helps the community grow by sharing knowledge.
Happy Coding


Java 8 – Default Methods in Interface

Java 8 arrived with new features and advances which has also interface with default methods in its arsenal too.

What we might have heard about default methods in interfaces?

  • Multiple inheritance.
  • Backward Compatibility.
  • Default methods reduces the need of abstract class.

While the first two points are correct but the last point is not though it seems to more or less works like the abstract class. I will keep it for last, and starts with some basic information.

Why we needed Default Methods inside Interface?

As it is said, when there are problems we look around for solutions , this is the case where it get fits. Think of a situation where one needs to declare a new method signature inside an interface, and that interface has been implemented in 100’s of classes.  Hhhuh!! That is a painful task as first it is mandatory to  implement it all the the new method in 100 instances and also we need to handle the situation where we don’t need that function.

What if we are allowed to write a default method definition inside interface?
Listen behind, someone whispering “Java 8 allows you to do so…

Continue reading

@ConfigurationProperties : Spring Boot’s way of handling properties

Hello coders,


We are always in quest of improving something or the other in our lifetime, this urge also fits in for technologies as well. We can see many enhancements and updates on each and every technology so as in our favourite Spring Framework.

Spring has come a long way ahead since its inceptions.. Yes, the latest buzz word is “SPRING BOOT”!! Though it has made a lot of things easier for a developer, but sometime it debatable. In a nutshell, understanding it deeply is a must.

Here, I will be sharing a tiny, may be a tiniest of a configuration annotations @ConfigurationProperties 

We must have used properties files in almost all of our applications. Spring Boot provides a clean and neat way of using it in applications. Instead of writing the long properties name which is very error-prone (we must have spent lot of time debugging and at last it just a spelling mistake of property name).

So, how about creating a class that gets mapped to properties on a file? Isn’t it a neat style?

Let’s get into coding. We used to start with writing the properties first, but here we can start designing a properties in a Class then move to properties file.

Create a class:


import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

public class JwtProperties {

    private String header;
    private String secret;
    private int expiration;
    private Map <String,String> authorisation;
    private List<String> someProperties;

//... Getters & Setters

This class is marked as @Component. Which makes it a candidate for @Autowiring. Also we have used @ConfigurationProperties(prefix=”jwt”), which indicates that this will get mapped to all properties starts with jwt. Lets have an look at the properties file (properties.yaml)

  expiration: 604800
  path: auth
  secret: secret
  username: sovanm
  salt: mysecr3t
    - prop1
    - prop2

Now the mapping is done, but how to use it? This must be simple. Yes you guessed it right. It is simple. Just Inject the Component and enjoy the get methods to get the values.

private JwtProperties jwtProperties;
// Constructor Injection
public JwtTokenUtils(JwtProperties jwtProperties) {
    this.jwtProperties = jwtProperties;
    System.out.println("Secret: " + this.jwtProperties.getSecret());
    System.out.println("SomePropertiesList: " +
        .forEach(e-> {
             System.out.println(e.getKey() + " : " + e.getValue());

Done! we can now use the properties anywhere in this class. It helps to make our work easier as we all love to use object intelligence rather than writing the string version as

private Map authorisations;

Features, that we can take advantages are:

  •  We can use JSR-303 Annotations for validations. (E,g: Used above)
  •  Intelligence available in the properties file.
  • We can load family of properties into separate classes using the appropriate prefix.

There are lots to know..but  I hope, this might help you getting started dealing with properties file in Boot’s way.

Thanks for reading and Happy Coding 🙂


Let us start the SPRING…

Hello Again..

It’s coding time now…and let us do some JAVA coding first then we will “Springify” that code using Spring Framework. It is a simple Java program with classes, interface, main class to bring together all classes to work as one application.

What will we do….

I know you guys will be sad because I promise to have some spring codes, but trust me staring with Springs right away will not that interesting…

Some Prerequisite…

  • IDE : I will be using STS. (SpringSource Tool Suite).
  • Knowledge of Java
That’s it for now..
Let us create a simple Contact Manager Application.
  • Create a Java Project (File -> New -> Java Project)
  • Create a Package “com.springwelcome.model” and inside that create a class ““. Here we are going to define what we need to store in as contacts. It is a simple POJO class with FirstName, LastName and PhoneNumber.
  • Let us now create another package that will contains the method dealing with data for Database Transactions. Here we are not going to use any database instead we will be using List to store information and return to our Service class. 
  • For this create a package “com.springwelcome.repo” and add a new class ““. You must be wondering why am I used …Implementation. Yes, I will using an interface. Let me add the code to make it clear. 

  • Here the question arises why are we using interface here, where we can use the class name directly while creating the instance. You are absolutely correct. In future we are going to learn about spring and we are going to convert this application using springs. In Spring we have an important concept “Inversion Of Control”. Lets move into this later….
  • As we have the Data Storage Class A.K.A. DAO (Data Access Object). To know more about  DAO please follow the link. Now let us create the service which will return us the names in the contact. 
  • Let me create a new package and name it as “com.springwelcome.service” and create a new class inside it as well and name it as ““. 
  •  Similarly we will be implementing an interface here as well. 

  • Now we are almost done with all the parts of this application, We just need to bring together all parts into one. Let us create a new class without any package and name it ““. This will contain the  entry point for out application. the MAIN class. 

That is it..we are done with a java application which will be SPRINGIFY soon..

    Hoping you get along with this easily…till next time when we will be doing some changes to implement springs…
    Happy coding.. 🙂