JAVA-931: Migrate spring-cloud-connectors-heroku to parent-boot-2
This commit is contained in:
parent
d34fe14d61
commit
694261868d
|
@ -9,9 +9,9 @@
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-boot-1</artifactId>
|
<artifactId>parent-boot-2</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../../parent-boot-1</relativePath>
|
<relativePath>../../parent-boot-2</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -35,6 +35,11 @@
|
||||||
<groupId>org.postgresql</groupId>
|
<groupId>org.postgresql</groupId>
|
||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.bytebuddy</groupId>
|
||||||
|
<artifactId>byte-buddy-dep</artifactId>
|
||||||
|
<version>${bytebuddy.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
|
@ -55,8 +60,9 @@
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
|
<spring-cloud-dependencies.version>Hoxton.SR4</spring-cloud-dependencies.version>
|
||||||
<postgresql.version>9.4-1201-jdbc4</postgresql.version>
|
<postgresql.version>42.2.10</postgresql.version>
|
||||||
|
<bytebuddy.version>1.10.10</bytebuddy.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -1,5 +1,7 @@
|
||||||
package com.baeldung.spring.cloud.connectors.heroku.book;
|
package com.baeldung.spring.cloud.connectors.heroku.book;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@ -15,7 +17,7 @@ public class BookController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{bookId}")
|
@GetMapping("/{bookId}")
|
||||||
public Book findBook(@PathVariable Long bookId) {
|
public Optional<Book> findBook(@PathVariable Long bookId) {
|
||||||
return bookService.findBookById(bookId);
|
return bookService.findBookById(bookId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.baeldung.spring.cloud.connectors.heroku.book;
|
package com.baeldung.spring.cloud.connectors.heroku.book;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
@ -15,8 +17,8 @@ public class BookService {
|
||||||
this.bookRepository = bookRepository;
|
this.bookRepository = bookRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Book findBookById(Long bookId) {
|
public Optional<Book> findBookById(Long bookId) {
|
||||||
return bookRepository.findOne(bookId);
|
return bookRepository.findById(bookId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(propagation = Propagation.REQUIRED)
|
@Transactional(propagation = Propagation.REQUIRED)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.baeldung.spring.cloud.connectors.heroku.product;
|
package com.baeldung.spring.cloud.connectors.heroku.product;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@ -15,7 +17,7 @@ public class ProductController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{productId}")
|
@GetMapping("/{productId}")
|
||||||
public Product findProduct(@PathVariable Long productId) {
|
public Optional<Product> findProduct(@PathVariable Long productId) {
|
||||||
return productService.findProductById(productId);
|
return productService.findProductById(productId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.baeldung.spring.cloud.connectors.heroku.product;
|
package com.baeldung.spring.cloud.connectors.heroku.product;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
@ -15,8 +17,8 @@ public class ProductService {
|
||||||
this.productRepository = productRepository;
|
this.productRepository = productRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Product findProductById(Long productId) {
|
public Optional<Product> findProductById(Long productId) {
|
||||||
return productRepository.findOne(productId);
|
return productRepository.findById(productId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(propagation = Propagation.REQUIRED)
|
@Transactional(propagation = Propagation.REQUIRED)
|
||||||
|
|
Loading…
Reference in New Issue