If we use java config for obj creation and other things is it not against IOC principle

42 Views Asked by At

when we use java config for meta-data config it is against IOC principle, we make use of new keyword?

1

There are 1 best solutions below

10
camtastic On BEST ANSWER

The new keyword for a dependency is used in the config class. The IOC principle still applies as long as managed spring beans have their dependencies supplied/injected by the spring container.

For example you can still reap the benefits of IOC like injecting mocks for dependencies for unit tests.

Plus you get added benefits using Java config like type safety and easier refactoring.