This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot-examples.git
The following commit(s) were added to refs/heads/main by this push:
new fd0cc5b A better suggestion about the annotation usage (#38)
fd0cc5b is described below
commit fd0cc5b72ffbf3bb787ec3f49e6e1bfcbdd83d4a
Author: William <[email protected]>
AuthorDate: Sun Oct 31 16:30:48 2021 +0800
A better suggestion about the annotation usage (#38)
Hi, I found that there may be some minor improvements about annotations in
your code.
A Spring bean in the service layer should be annotated using @service
instead of @component annotation.
@service annotation is a specialization of @component in service layer. By
using a specialized annotation we hit two birds with one stone. First, they are
treated as Spring bean, and second, you can put special behavior required by
that layer.
For better understanding and maintainability of a large application,
@service is a better choice.
---
.../org/apache/camel/example/spring/boot/rest/jpa/OrderService.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git
a/rest-jpa/src/main/java/org/apache/camel/example/spring/boot/rest/jpa/OrderService.java
b/rest-jpa/src/main/java/org/apache/camel/example/spring/boot/rest/jpa/OrderService.java
index 94ac142..c55599f 100644
---
a/rest-jpa/src/main/java/org/apache/camel/example/spring/boot/rest/jpa/OrderService.java
+++
b/rest-jpa/src/main/java/org/apache/camel/example/spring/boot/rest/jpa/OrderService.java
@@ -19,9 +19,9 @@ package org.apache.camel.example.spring.boot.rest.jpa;
import java.util.Random;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Serivce;
-@Component
+@Serivce
public class OrderService {
private final BookRepository books;