Dependency injection in all aspects of a spring application?

I see Spring as a web framework, however I need a little help to get my head around DI.

The concept of objects created in a container at runtime is such a new concept.

I'm just wondering how this will affect a large application, will I have some modules that perform work with higher connectivity, or each initialized object at runtime?

For me, all this seems a bit intense, I mean, for example, I have a data mining application in CSV that deletes data in each row - each row of data is encapsulated in one of my own objects CSVRowfor processing or something else , These objects are created every time an Excel file can be uploaded to the server. I do not know how much I will need to create?

I seem to be a little lost, clarity, review or some kind of guidance will be greatly appreciated.

Thanks in advance!

+3
source share
4 answers

I will try to say simply:

  • use dependency injection for stateless classes that have logic (business logic, persistence logic, interface logic)
  • new
+4

, , -.
( ).
, , : 1)
2) , , , , .
, , , " " , .
, , , , CsvRow, Spring ( ) . , , CsvRow2 ( ),

+3

DI CSV. , , CSVRow . .

, , , . applicationContext beans . , CsvRow , Spring, .

+1

I think of Spring as a way to create singletons. When I want to guarantee that there is only one instance of a class in an application, use Spring to create it. But instead of the traditional singleton with a static field INSTANCEor similar, it's a POJO with any constructors / setters you need. Spring creates an instance at runtime for you and ensures that creation only happens once.

+1
source

All Articles