1

I was reading about Spring core module and came across Spring annotations that I did not see till now in the Hybris project:

@Component,@Qualifier

Are these used in Hybris projects?

Rachit
  • 403
  • 10
  • 32

2 Answers2

0

Hybris 6.6 uses Spring 4.3. The usual annotations like @Autowired, @Required, @Controller, and many others should work.

If you have access to Hybris Help, have a look at "Spring Framework in SAP Commerce": https://help.hybris.com/6.6.0/hcd/8c63621986691014a7e0a18695d7d410.html

There is:

  • Dependency Injection
  • Interface-Driven Design
  • Beans (and aliasing)
  • Spring Profiles
  • Spring MVC
  • Spring Integration
  • etc
geffchang
  • 3,279
  • 2
  • 32
  • 58
  • Thanks a lot.However I have not seen Component and Qualifier annotations.Are they supported? – Rachit Apr 20 '19 at 05:19
  • @Rachit I've seen Qualifier used in Hybris' JUnit codes, and Component used in validators. – geffchang Apr 20 '19 at 05:43
  • Normally do you suggest using it in a normal scenario when you call Facade from your controller and go to the DAO later to retrieve something ? – Rachit Apr 20 '19 at 05:44
  • As @Mafick mentioned, it depends on you. You can use either XML configuration or annotations (as long component scanning is enabled). In practice, you will most likely be using both. – geffchang Apr 21 '19 at 08:38
0

Hybris uses both. Annotation Injection and XML Injection. You can also use both. I recommend you, to define a clear strategy when you use which one.

For example:

Controller - Annotation Injection
Facade - XML Injection
Service - XML Injection

To your point, which kind of Annotation you should use, have a look here: What's the difference between @Component, @Repository & @Service annotations in Spring?

In common said, there is not really a different. It's just nice to use the correct Annotation for the correct class.

Mafick
  • 1,128
  • 1
  • 12
  • 27