This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot-examples.git


The following commit(s) were added to refs/heads/master by this push:
     new 9472d5c  Fixed rest jpa example
9472d5c is described below

commit 9472d5c91861c214c620a85deaea132955cfb861
Author: Farid Guliyev <fg7...@gmail.com>
AuthorDate: Tue Oct 27 13:57:30 2020 -0400

    Fixed rest jpa example
---
 .../apache/camel/example/spring/boot/rest/jpa/Database.java  | 12 +++++++-----
 .../camel/example/spring/boot/rest/jpa/OrderService.java     |  7 +++++--
 .../src/main/resources/application.yml                       |  3 ++-
 .../camel/example/spring/boot/rest/jpa/ApplicationTest.java  |  1 -
 .../src/test/resources/application.yml                       |  3 ++-
 5 files changed, 16 insertions(+), 10 deletions(-)

diff --git 
a/camel-example-spring-boot-rest-jpa/src/main/java/org/apache/camel/example/spring/boot/rest/jpa/Database.java
 
b/camel-example-spring-boot-rest-jpa/src/main/java/org/apache/camel/example/spring/boot/rest/jpa/Database.java
index 4b988db..1b4f1dc 100644
--- 
a/camel-example-spring-boot-rest-jpa/src/main/java/org/apache/camel/example/spring/boot/rest/jpa/Database.java
+++ 
b/camel-example-spring-boot-rest-jpa/src/main/java/org/apache/camel/example/spring/boot/rest/jpa/Database.java
@@ -16,17 +16,19 @@
  */
 package org.apache.camel.example.spring.boot.rest.jpa;
 
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 @Component
 public class Database {
 
-    @Autowired
-    BookRepository books;
+    private final BookRepository books;
 
-    @Autowired
-    OrderRepository orders;
+    private final OrderRepository orders;
+
+    public Database(BookRepository books, OrderRepository orders) {
+        this.books = books;
+        this.orders = orders;
+    }
 
     public Iterable<Book> findBooks() {
         return books.findAll();
diff --git 
a/camel-example-spring-boot-rest-jpa/src/main/java/org/apache/camel/example/spring/boot/rest/jpa/OrderService.java
 
b/camel-example-spring-boot-rest-jpa/src/main/java/org/apache/camel/example/spring/boot/rest/jpa/OrderService.java
index 8c173f8..94ac142 100644
--- 
a/camel-example-spring-boot-rest-jpa/src/main/java/org/apache/camel/example/spring/boot/rest/jpa/OrderService.java
+++ 
b/camel-example-spring-boot-rest-jpa/src/main/java/org/apache/camel/example/spring/boot/rest/jpa/OrderService.java
@@ -24,11 +24,14 @@ import org.springframework.stereotype.Component;
 @Component
 public class OrderService {
 
-    @Autowired
-    private BookRepository books;
+    private final BookRepository books;
 
     private final Random amount = new Random();
 
+    public OrderService(BookRepository books) {
+        this.books = books;
+    }
+
     public Order generateOrder() {
         Order order = new Order();
         order.setAmount(amount.nextInt(10) + 1);
diff --git 
a/camel-example-spring-boot-rest-jpa/src/main/resources/application.yml 
b/camel-example-spring-boot-rest-jpa/src/main/resources/application.yml
index badb2fd..f473f45 100644
--- a/camel-example-spring-boot-rest-jpa/src/main/resources/application.yml
+++ b/camel-example-spring-boot-rest-jpa/src/main/resources/application.yml
@@ -19,7 +19,8 @@ camel:
   springboot:
     # The Camel context name
     name: CamelRestJpa
-
+  rest:
+    component: servlet
   component:
     servlet:
       mapping:
diff --git 
a/camel-example-spring-boot-rest-jpa/src/test/java/org/apache/camel/example/spring/boot/rest/jpa/ApplicationTest.java
 
b/camel-example-spring-boot-rest-jpa/src/test/java/org/apache/camel/example/spring/boot/rest/jpa/ApplicationTest.java
index 0894e2d..a41e13e 100644
--- 
a/camel-example-spring-boot-rest-jpa/src/test/java/org/apache/camel/example/spring/boot/rest/jpa/ApplicationTest.java
+++ 
b/camel-example-spring-boot-rest-jpa/src/test/java/org/apache/camel/example/spring/boot/rest/jpa/ApplicationTest.java
@@ -39,7 +39,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 @CamelSpringBootTest
 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@Disabled("Remove if you have running MySQL v8 instance on port 3306 and with 
user cameluser")
 public class ApplicationTest {
 
     @Autowired
diff --git 
a/camel-example-spring-boot-rest-jpa/src/test/resources/application.yml 
b/camel-example-spring-boot-rest-jpa/src/test/resources/application.yml
index acfe10e..12613e3 100644
--- a/camel-example-spring-boot-rest-jpa/src/test/resources/application.yml
+++ b/camel-example-spring-boot-rest-jpa/src/test/resources/application.yml
@@ -18,7 +18,8 @@
 camel:
   springboot:
     name: CamelRestJpa
-
+  rest:
+    component: servlet
   component:
     servlet:
       mapping:

Reply via email to