JAVA-931: Migrate spring-cloud-connectors-heroku to parent-boot-2

This commit is contained in:
sampadawagde 2020-06-08 12:59:01 +05:30
parent d34fe14d61
commit 694261868d
5 changed files with 24 additions and 10 deletions

View File

@ -9,9 +9,9 @@
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-boot-1</artifactId>
<artifactId>parent-boot-2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-boot-1</relativePath>
<relativePath>../../parent-boot-2</relativePath>
</parent>
<dependencies>
@ -35,6 +35,11 @@
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-dep</artifactId>
<version>${bytebuddy.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
@ -55,8 +60,9 @@
</dependencyManagement>
<properties>
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
<postgresql.version>9.4-1201-jdbc4</postgresql.version>
<spring-cloud-dependencies.version>Hoxton.SR4</spring-cloud-dependencies.version>
<postgresql.version>42.2.10</postgresql.version>
<bytebuddy.version>1.10.10</bytebuddy.version>
</properties>
</project>

View File

@ -1,5 +1,7 @@
package com.baeldung.spring.cloud.connectors.heroku.book;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -15,7 +17,7 @@ public class BookController {
}
@GetMapping("/{bookId}")
public Book findBook(@PathVariable Long bookId) {
public Optional<Book> findBook(@PathVariable Long bookId) {
return bookService.findBookById(bookId);
}

View File

@ -1,5 +1,7 @@
package com.baeldung.spring.cloud.connectors.heroku.book;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@ -15,8 +17,8 @@ public class BookService {
this.bookRepository = bookRepository;
}
public Book findBookById(Long bookId) {
return bookRepository.findOne(bookId);
public Optional<Book> findBookById(Long bookId) {
return bookRepository.findById(bookId);
}
@Transactional(propagation = Propagation.REQUIRED)

View File

@ -1,5 +1,7 @@
package com.baeldung.spring.cloud.connectors.heroku.product;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -15,7 +17,7 @@ public class ProductController {
}
@GetMapping("/{productId}")
public Product findProduct(@PathVariable Long productId) {
public Optional<Product> findProduct(@PathVariable Long productId) {
return productService.findProductById(productId);
}

View File

@ -1,5 +1,7 @@
package com.baeldung.spring.cloud.connectors.heroku.product;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@ -15,8 +17,8 @@ public class ProductService {
this.productRepository = productRepository;
}
public Product findProductById(Long productId) {
return productRepository.findOne(productId);
public Optional<Product> findProductById(Long productId) {
return productRepository.findById(productId);
}
@Transactional(propagation = Propagation.REQUIRED)