DEV Community

Netsai
Netsai

Posted on

From a Java Console Banking App to a Spring Boot REST API

Postman showing a successful GET request to the Spring Boot Banking API returning a JSON list of bank accounts-When I first started learning Java, my banking application was nothing more than a console program. Everything happened inside a main() method—creating accounts, depositing money, withdrawing funds, and transferring money between accounts.

  • While that taught me the fundamentals of Java, I knew real backend applications worked differently.

Over the past few weeks, I've been transforming that console application into a Spring Boot backend, and it's been an eye-opening experience.

What I've Built So Far
Core Java Foundation

Before touching Spring Boot, I focused on mastering Java fundamentals:

  • Object-Oriented Programming
  • Inheritance
  • Polymorphism
  • Interfaces
  • Abstract Classes
  • Exception Handling
  • Collections
  • Streams API
  • Enums
  • JUnit Testing
  • Gradle
  • Git & GitHub

That foundation made learning Spring much easier.

Enter Spring Boot

My first Spring Boot application felt surprisingly simple:

@SpringBootApplication
public class BankingApiApplication {

public static void main(String[] args) {
    SpringApplication.run(BankingApiApplication.class, args);
}
Enter fullscreen mode Exit fullscreen mode

With just a few annotations, I had a web server running.

Building My First REST API

The first endpoint I created was:

@RestController
public class HomeController {

@GetMapping("/")
public String home() {
    return "Welcome to my Banking API!";
}
Enter fullscreen mode Exit fullscreen mode

Seeing text returned in a browser instead of the console was a memorable milestone.

Understanding Dependency Injection

One concept that really changed how I think about software design was Dependency Injection.

Instead of writing:

BankService service = new BankService();

Spring creates and injects the service for me:

@RestController
public class AccountController {

private final BankService bankService;

public AccountController(BankService bankService) {
    this.bankService = bankService;
}
Enter fullscreen mode Exit fullscreen mode

This keeps the code cleaner, easier to test, and more maintainable.

Creating REST Endpoints

I added endpoints to:

  • Retrieve all accounts
  • Create new accounts
  • Search accounts by account number
  • Testing them with Postman helped me understand how frontend and backend applications communicate through HTTP and JSON.
  • Learning Proper Error Handling
  • Instead of returning null when an account doesn't exist, I implemented custom exceptions and global exception handling.
  • This allowed my API to return meaningful HTTP responses such as:
  • 404 Not Found
  • Structured JSON error messages
  • This made the API much more professional.
  • Moving from Memory to PostgreSQL

Initially, my application stored data inside an ArrayList.

Eventually, I replaced it with:

  • PostgreSQL
  • Spring Data JPA
  • JpaRepository

Instead of manually managing collections, Spring now handles persistence through repositories.

Introducing DTOs

One lesson that stood out was why professional applications don't expose database entities directly.

I learned to separate:

  • Request DTOs
  • Response DTOs
  • Database Entities

This makes the API cleaner, safer, and easier to evolve over time.

Looking Back

It's interesting to compare where I started and where I am now.

  • Then
  • Console application
  • System.out.println()
  • ArrayList
  • Manual object creation
  • Now
  • Spring Boot
  • REST APIs
  • Dependency Injection
  • Controllers
  • Services
  • Repositories
  • PostgreSQL
  • DTOs
  • Postman
  • JUnit

The concepts I learned in Core Java didn't disappear—they became the foundation for everything I built with Spring Boot.

What's Next?

I'm continuing to expand this banking API by learning:

  1. Bean Validation
  2. Spring Security
  3. JWT Authentication
  4. Docker
  5. Integration Testing
  6. Deployment

Every feature brings the project closer to what you'd expect in a production backend application.

If you're learning Java, my advice is simple:

Don't rush into frameworks. Build a strong Core Java foundation first. When you eventually learn Spring Boot, you'll understand not just how things work, but why they work that way.

Thanks for reading! If you're on a similar backend development journey, I'd love to connect and hear what you're building.

Top comments (0)