Springboot

1.What is Springboot ?

Spring Boot is a system from “The Spring Team” to facilitate the bootstrapping and development of new Spring Applications. It gives defaults to code, and annotation configurations to snappy begin new spring projects at no time. It takes after the “Opinionated Defaults Configuration” Approach to escape from a lot of standard code and configuration to enhance Development, Unit Test, and Integration Test Process.

2. What are Actuator in Spring Boot ?

Spring Boot is a system from “The Spring Team” to facilitate the bootstrapping and development of new Spring Applications. It gives defaults to code, and annotation configurations to snappy begin new spring projects at no time. It takes after the “Opinionated Defaults Configuration” Approach to escape from a lot of standard code and configuration to enhance Development, Unit Test, and Integration Test Process.

3. How to add custom JS code in Spring Boot ?

/src/main/resources/static is the suggested folder for static content in Spring boot.

You can create a JS file for sending an alert by creating a custom file named custom.js in /src/main/resources/static/js/ directory with below code

alert("Hello World");

4. Why is it “opinionated”?

It follows “Opinionated Defaults Configuration” Approach to reduce Developer effort. Due to opinionated view of spring boot, what is required to get started but also we can get out if not suitable for application.
Spring Boot uses sensible defaults, “opinions”, mostly based on the classpath contents.
For example
Sets up a JPA Entity Manager Factory if a JPA implementation is on the classpath.
Creates a default Spring MVC setup, if Spring MVC is on the classpath.
Everything can be overridden easily.
But most of the time not needed.

5. List minimum requirement for Spring boot System ?

Spring Boot 1.5.10. RELEASE requires

  • Java 7 +
  • Spring 4.3.13 +

For build support

  • Maven 3.2+
  • Gradle 2.9+

Container Support

  • Tomcat 7+
  • Jetty 8+ (Jetty 9.3 requires JDK 8 +)

6. Would you be able to Control Logging with Spring Boot? How ?

Yes, we can control logging with spring boot.

7. What is Auto Configuration in Spring boot ?

Autoconfiguration is way in Spring Boot to configure a spring application automatically on the basis of dependencies that are present on the classpath. It makes development easier and faster.

You can create a custom configuration for a MySQL data source in spring boot as

@Configuration
public class MySQLAutoconfiguration {
//...
}

8. What is the Name of Configuration File, Which you use in Spring Boot ?

Configuration file name which is utilized as a part of Spring boot ventures is known as application. Properties. It is vital to document as it is utilized to abrogate all default configurations.

9. How are properties defined ? Where ?

In spring boot, we have to define properties in the application.properties file exists in classpath of application as follow.
Example: configure default DataSource bean

database.host=localhost
database.user=admin

10. Advantage of using Spring Boot ?

  • It is quite easy to create Spring Based applications with Java or Groovy.
  • It lessens lots of improvement time and expands profitability.
    It abstains from writing lots of standard Codes, Annotations, and XML Configuration.
  • It is quite easy to coordinate Spring Boot Application with its Spring Ecosystem like Spring JDBC, Spring ORM, Spring Data, Spring Security and so forth.
  • It takes after the “Opinionated Defaults Configuration” Approach to diminish Developer effort.
  • It gives Embedded HTTP servers like Tomcat, Jetty and more to create and test our web applications effectively.
  • It gives CLI (Command Line Interface) tool to create and test Spring Boot (Java or Groovy) Applications from commanding prompt very easily and rapidly.
  • It gives lots of modules to create and test Spring Boot Applications effectively utilizing Build Tools like Maven and Gradle.
  • It provides loads of plug-ins to work with implanted and in-memory Databases effortlessly.

11. What does Spring Security mean ?

Spring Security is a groundbreaking and very adjustable authentication and access-control structure. It is the true standard for securing Spring-based applications. Spring Security is a system that spotlights on giving both authentication and approval to Java applications. Like all spring ventures, the genuine power of Spring Security is found in how effectively it can be reached out to meet custom prerequisites.

12. List down features of Spring Boot ?

Various Spring Boot Features are as follows:

  • Web Development
  • Spring Application
  • Application occasions and listeners
  • Admin highlights
  • Externalized Configuration
  • Properties Files
  • YAML Support
  • Type-safe Configuration
  • Logging
  • Security

13. Describe some of the spring sub-projects briefly ?

  • JDBC: this module empowers a JDBC-deliberation layer that evaluates the need to do JDBC coding for particular vendor databases
  • Core: a key module that gives basic parts of the system, as IoC or DI
  • Web: a web-situated joining module, giving multipart document upload, listeners members, and web-arranged application context functionalities
  • ORM integration: gives mix layers to well-known protest object-relational mapping APIs, for example, JPA, JDO, and Hibernate
  • AOP module: perspective oriented programming execution is permitting the meaning of clean strategy interceptors and pointcuts.
  • MVC system: a web module executing the Model View Controller configuration design

14. How to connect to an external database like MSSQL or oracle with Spring boot ?

Step 1 -The first step to connect the database like Oracle or MySql is adding the dependency for your database connector to pom.xml.

Step 2 -The next step is the elimination of H2 Dependency from pom.xml

Step 3 -Step 3 includes the schema and table to establish your database.

Step 4 -The next step is configuring of the database by using Configure application.properties to connect to your database.

Step 5-And the last step is to restart your device and your connection is ready to use.

15. Explain the difference between JPA and Hibernate ?

JPA is a specification/Interface whereas Hibernate is one of the JPA implementations.

16. What does Aspect-Oriented Programming (AOP) mean ?

Aspect Oriented Programming (AOP) supplements Object-Oriented Programming (OOP) by giving another mindset about program structure. The key unit of measured quality in OOP is the class, while in AOP the unit of particularity is the viewpoint. Angles empower the modularization of concerns, for example, transaction management that cut over numerous sorts and questions.

17. What is the reason to have a spring-boot-maven module ?

The reason behind to have Spring-boot-maven module is it gives a couple of charges which empower you to package the code as a container or run the application

  • spring-boot: run operates your Spring Boot application.
  • spring-boot: repackage it repackages your jug/war to be executable.
  • spring-boot: start and spring-boot: stop to deal with the lifecycle of your Spring Boot application (i.e., for joining tests).
  • spring-boot: build-data creates build data that can be utilized by the Actuator.

18. What do Dev Tools in Spring boot mean ?

Spring boot accompanies Dev Tools, which is acquainted with increase the profitability of designer. You don’t have to redeploy your application each time you influence the changes. The developer can reload the progressions without restart of the server. It maintains a strategic distance from the agony of redeploying application each time when you roll out any improvement. This module will can’t be utilized in a production environment.

19. What does Spring boot Starter Pom mean? Why is it useful ?

Starters are an arrangement of advantageous reliance descriptors that you can incorporate into your application. The starters contain a considerable amount of the dependencies that you have to get a task up and running rapidly and with a steady, supported a set of managed transitive conditions.

The starter POMs are helpful reliance descriptors that can be added to your application’s Maven. In another word, if you are building up a project that utilizes Spring Batch for batch preparing, you need to incorporate spring-boot-starter-bunch that will import all the required conditions for the Spring Batch application. This decreases the burden of looking at and designing all of the conditions required for a structure.

20. Would we able to Use Spring Boot with Applications which are not Using Spring ?

No, it isn’t conceivable starting at now. Spring boot is restricted to Spring applications only.

21. What is thymleaf ?

It is a server side Java template engine for web application. It’s main goal is to bring elegant natural templates to your web application.

It can be integrate with Spring Framework and ideal for HTML5 Java web applications.

22. How to use thymleaf ?

In order to use Thymeleaf we must add it into our pom.xml file like:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>    

23. What is @RestController annotation in Spring Boot?

The @RestController is a stereotype annotation. It adds @Controller and @ResponseBody annotations to the class. We need to import org.springframework.web.bind.annotation package in our file, in order to implement it.

24. What is @RequestMapping annotation in Spring Boot?

The @RequestMapping annotation is used to provide routing information. It tells to the Spring that any HTTP request should map to the corresponding method. We need to import org.springframework.web.annotation package in our file.

25. What are Spring Boot Starter Project ?

Starters are a set of convenient dependency descriptors that you can include in your application. You get a one-stop-shop for all the Spring and related technology that you need, without having to hunt through sample code and copy paste loads of dependency descriptors.

For example, if you want to get started using Spring and JPA for database access, just include the spring-boot-starter-data-jpa dependency in your project, and you are good to go.

Related Articles

Core Java

1. What are primitive types in Java ? byte, short, int, long, float, double, char, boolean… 2. What are tokens? Name the 5 types of tokens available in Java with an example…

Spring

1. Hello World Program HelloWorld.java MainApp.java 2. How to create Spring applcation. Create Java Class Create XML File Create test class Load jar files required…

Hackerearth-Java

     1. Challenge : Welcome to Java! Welcome to the world of Java! In this challenge, we practice printing to stdout. The code stubs…

Responses

Your email address will not be published. Required fields are marked *

×