What is this Spring? 🌱

Shanira Perera
3 min readSep 2, 2022

Spring Fundamentals

Hello and welcome everyone to another Techie Talk. Today I am going to talk about another wonderful topic of Spring.

What is this Spring?

Spring is an application framework and inversion of control container for the Java platform. and it Originally build to reduce the complexity of Enterprise Java Development, It is POJO based and interface driven, Very lightweight compared to old J2EE methodologies & build around patterns and best practices (singleton , factory and etc.).

Benefits of it

  • Can do Testability
  • Contain Maintainability
  • Scalability
  • Handle Complexity
  • Run complex code in faster
  • Code can focus on testing
  • Can remove configuration from codebase.

Prerequisites of need

  • Java 7 (5 or above)
  • Eclipse Juno or later (Spring sts-3.X.X.RELEASE IDE is Preferred.)
  • spring-framework-3.2.4.RELEASE (or 3.x)

Lets Start Spring Project and see how its work!!!!!…………………………..

01).First use this link and initialize spring → https://start.spring.io/

https://start.spring.io/
Click this to add Dependencies
Collection of Dependencies

In this dependency list you can use whatever you want, im use Spring Web because we are going to create simple restful web service to test our Spring project.

After adding all the dependencies click this GENERATE then it will download automatically.

02). Open Eclipse IDE and import this project

Import Project

03). Select Existing maven project and import it

Select ProjectType

04) After click browse and select the project that we extracted, then you can see it on your project explorer.

After adding the project to Eclipse

05) Now we create more packages as Model, Repository & Service.

06). Create Model package as com.shanira.training.salesmanager.model

Employee.java

Create class called Employee.java and Generate Getters and Setters for employeeName and employeeLocation variables.

07).Create Repository package as com.shanira.training.salesmanager.repository

HibernateEmployeeRepositoryImpl.java

Create class called HibernateEmployeeRepositoryImpl.java inside the repository package.

Using interfaces is a key factor in making your code easily testable in addition to removing unnecessary couplings between your classes.

Support for safety of changes

• List myList = new ArrayList(); // programming to the List interface

  • This will ensures that you only call methods on myList that are defined by the List interface (so no ArrayList specific methods)
  • later on you can decide that you really need
  • List myList = new TreeList();

08) Refactor the interface

Refactor the Interface

Tick the✅ getAllEmployees(): List<Employee>

Interface Name : EmployeeRepository

09).Create Service package as com.shanira.training.salesmanager.service

Inside that create class called EmployeeServiceImpl.java and create Interface also.

EmployeeServiceImpl.java

Now you can run and see the output in the console you can get the port 8080(it can be different ) enter it in browser and get the output as shanira at kandana.

reference : https://krishantha.com/decks/spring/

Hope you see on next Article !!!! 🔥🔥🔥🔥🔥

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Shanira Perera
Shanira Perera

Written by Shanira Perera

Hello, I’m Shanira, welcome to the world of technology. I am an Associate software engineer at virtusa. So let’s begin!

No responses yet

Write a response