@Pete O'Hanlon thanks, I've resolved it, I got help from someone. I had to replace this dependency
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
with this -
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
In the first dependency above spring security scope was set to test which can only be used for Unit Testing but for a regular spring security application, the second dependency was to be used. Thanks @Pete O'Hanlon and @Andre Oosthuizen. Issue resolved.