Spring Boot Interview Question

Q1. What is key advantage of using Spring Boot?
Ans: You can "build a production ready application from scratch in a matter of minuts" Spring boot is a Spring Module which
provide RAD(Rapid Application Deployment) feature to Spring framework.

Q2 Which annotation used in SpringBoot?
Ans: 
     @ Bean:Indicates that a method produces a bean to managed by Spring.
     @ Service :Indicates that an annotatited class is serives class.
     @ Repository :indicates tha an annotated class is repository,Which is abstraction of  data acess and storage.
     @ Configuration -Indicates that a class is configuration class that may contain bean definitions.
     @ Controller : marks the class as web controller,capable of handling the request.
     @ RequestMapping :  Maps HTTP request with a path to controller method.
     @ Autowited :Marks a constructor ,field or setter method to autowited by Spring dependency injection.
     @SpringBootapplicaiton :Enable Spring Boot autoconfiguration and components scanning

Q3. Differance between CommandlineRunner and ApplicaitonRunner in Spring Boot?
Ans: Both are similar in terms of functionality and the deiiferance is that If you need access to ApplicaitonArguments instead of
the row String array conside using ApplicaitonRunner then CommandLineRunner.

Q4. How to used @SpringBootApplication in SpringBoot application?
Ans: @SpringBootApplication annotation is equivalant to using @Configuration,@EnableAtoConfiguratin and @ComponentScan with their
default attributs:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringBootWebApplication {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(SpringBootWebApplication.class, args);
    }
}

Bellow paramaters are accepted in the @SpringBootApplication
scanBasePackage -Provide the list of packages that has to be applied for the @ComponentScan.This Paramater added since Spring boot 1.3
scanBasePackageClasses:Provide the list of classess that has to be applicaed for @ComponentScan

exclude :Exclude the list of classes from the auto Configuration. 

No comments: