Spring Framework
Learn about a few interview questions regarding the Spring framework.
We'll cover the following
- What are the major features of Spring 5?
- Is Spring 5 compatible with older versions of Java?
- What are the advantages of using the Spring framework?
- What is tight coupling?
- What is loose coupling?
- What is the purpose of application.properties file?
- What is pom.xml file?
- What design patterns are used in the Spring framework?
- What are some of the best practices for Spring Framework?
- How does Spring 5 make use of JDK 9 modularity?
What are the major features of Spring 5?
Spring 5 was released in 2017. Its major features include:
- It requires a minimum of Java 8.
- It enables the use of lambda expressions.
- It is based on servlet 4.0 API.
- It includes the reactive programming framework WebFlux.
- Spring 5 supports Kotlin for functional programming.
- It enables JUnit 5 support for testing.
Is Spring 5 compatible with older versions of Java?
No, because Spring 5 requires a minimum of Java 8. It is not compatible with older versions of Java as the code base of Spring has been revamped to take advantage of the features of Java 8.
What are the advantages of using the Spring framework?
- Spring framework is open source.
- Spring framework was designed to reduce boilerplate code.
- Dependency injection makes it possible to write loosely coupled code, which is easy to modify and maintain.
- Spring architecture is modular, which makes it a lightweight framework. The developer has the choice to pick and choose only those modules which are needed for the application.
- Spring also provides excellent integration with a number of frameworks like Hibernate, Struts, EJB, etc.
- The autoconfiguration feature reduces the development time, where the developer only focuses on the business logic while Spring takes care of the configuration details.
- Spring supports AOP, which separates business logic from system services.
- Spring provides an API for translating technology-specific exceptions into unchecked exceptions.
- Spring supports testable code and test-driven development (TDD).
List the modules of the Spring framework
Spring architecture is modular. The modules can be grouped together based on their functionality.
- The Spring Core Container has Core, Beans, Context, and Expression language modules.
- The data access or integration layer has JDBC, ORM, OXM, JSM, and Transaction modules.
- The web layer has Web, Servlet, Portlet, Struts, etc modules.
- Other modules include Test, AOP, Aspects, and Instrumentation.
Get hands-on with 1400+ tech skills courses.