1

I am new to Spring and Java in general. I am working on a REST API and want to use Spring. I have read the Spring docs on getting started with Spring but most of them only talk about how to start a Spring project from scratch. I already have an existing Maven project and want to add Spring to that. Can anyone help with that?

I'm using IntelliJ CE 2020.3 if that helps.

Daolly Mul
  • 11
  • 2
  • Does this answer your question? [add spring boot to existing project without changing the main(args\[\]) method](https://stackoverflow.com/questions/39816394/add-spring-boot-to-existing-project-without-changing-the-mainargs-method) – ALUFTW Feb 11 '21 at 01:58

1 Answers1

4

Using Spring actually impacts the organisation of your code, and Spring boot even more. I don't know the size of your existing project, but my first idea would be to build a new application structure using spring boot, then copy the "flesh" of your existing code into this structure, step by step.

Using only chosen bits of Spring / Spring boot is difficult, and certainly dangerous (for mental health) with no experience.

hth

Pierre Sevrain
  • 699
  • 4
  • 14
  • "certainly dangerous for mental health": thanks for the giggle! Also, my (to date, somewhat limited) experience of Spring Boot suggests that this is indeed the best approach. – sunrise Feb 11 '21 at 00:26
  • Using spring nor spring boot impacts the organisation of your code. It might require some additional setup to get your current structure working but you dn't need to restructure things. – M. Deinum Feb 11 '21 at 07:23
  • Makes sense, I guess I'll just build a new Spring Boot project within the existing package hierarchy and then `@Service` my existing class. – Egor Hans Feb 24 '23 at 16:57