Spring vs JAX-RS - spring

Here, several questions have been asked by many developers about difference between Spring-Rest and JAX-RS.
And, I have also learned that Spring is not following any specification and Spring framework has their own implementation then
Why Spring allows all that Annotations which are supported/used by JAX-RS by default?

Spring does not support JAX-RS annotations. If there is a situation where you think they do, then you are mistaken or it's just a coincidence. Period. If you will add any JAX-RS annotations in my Spring MVC program, nothing will happen. Annotations are just metadata. They are not programs. If Spring does not recognize the metadata, it will ignore it. But if you use a JAX-RS annotation in place of a Spring annotation that is used for the same purpose, respective of their framework, then you will not get the expected Spring behavior. So basically, if you are using Spring MVC, remove any JAX-RS dependencies so you don't mistakenly use them.

Related

Is Spring Rest the implementation of JAX-RS or what implementation does Spring Rest use for REST support?

I know JAX-RS has many implementations like RESTEASY,Jersy,RestLet.But when i use Spring boot project i just need to add Spring-web dependency and i am ready to go for creating REST APIs.I want to know what is the implementation Spring Boot Rest uses to support REST ?
Difference between JAX-RS and Spring Rest
hope that solves your problem or makes it a little clearer.

What Spring annotations can we use in Hybris commerce project?

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?
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.
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

List of Spring Boot provided beans?

Is there a list of beans provided by Spring Boot and its different modules? For example, I only recently discovered that Spring Boot already provides a configurable Jackson ObjectMapper bean. I would have never known that if not for reading up on an unrelated issue I was dealing with. Now I'm working with Spring JMS and am afraid that I am reinventing the wheel because Spring Boot may already have what I need and I just don't know about it. How are these beans discovered? They don't seem to be cataloged in any Spring documentation.
I would recommend starting with the reference documentation. While it doesn't list every bean that may be auto-configured, it does have documentation describing each feature area that may be auto-configured. For example, there are sections on Jackson's ObjectMapper and on JMS.
Each starter that Spring Boot offers is also a good indication of what it can auto-configure. Each first-party starter is listed in the documentation.

thymeleaf vs thymeleaf-spring4 dependency

Question is simple, what is the difference between the above dependencies? Does the first one enough for a springboot app or the second contains something special?
Artifact thymeleaf is the Core library.
Artifact thymeleaf-spring4 allows to integrate Thymeleaf with the Spring Framework, especially (but not only) Spring MVC. Btw there are several Thymeleaf integration packages for different Spring versions are available at the moment:
thymeleaf-spring3, thymeleaf-spring4, thymeleaf-spring5.
Information from thymeleaf-spring official documentation:
Thymeleaf offers a set of Spring integrations that allow you to use it as a fully-featured substitute for JSP in Spring MVC applications.
These integrations will allow you to:
Make the mapped methods in your Spring MVC #Controller objects forward to templates managed by Thymeleaf, exactly like you do with JSPs.
Use Spring Expression Language (Spring EL) instead of OGNL in your templates.
Create forms in your templates that are completely integrated with your form-backing beans and result bindings, including the use of property editors, conversion services and validation error handling.
Display internationalization messages from message files managed by Spring (through the usual MessageSource objects).
Resolve your templates using Spring’s own resource resolution mechanisms.
If you use Spring Boot, you can just use the spring-boot-starter-thymeleaf dependency. It already contains the above two dependencies as well as some others.

What is the best way to have interceptors for POJO?

EJB 3.0 comes with the concept of Interceptors, but then again they are applicable to EJBs only. My project requires developing Interceptors for POJO classes. One option for this is to use Spring AOP. I want to know if it's worth the overhead of including the libraries such as commons-logging, spring-aop, cglib that are required for Spring AOP.
Spring is much more than Spring AOP, and you can not use Spring AOP without Spring, and I am talking not only to the Spring libs, but to the Spring programming model too!
So if you think Spring is useful for your application (believe me, it is very useful to many application), then you can use it. - But it is a complete programming model, like EJB, not only a lib or a simple framework.
But I think every modern not trivial application should have a ICO container, so Spring is one of the choices you have.
Sure, it's worth, but be aware it won't be enough if you need to have interceptors for you POJOs : You will also need a "spring agent" to be passed as an argument to your jvm ("Load-Time Weaving"), or you won't be able to intercept your pojos methods, or you will have to use "Compile-Time Weaving".
In short : POJOs have to be created via Spring for them to be "interceptable".
CTW (or LTW) makes compilation (or startup) quite slower.

Resources