Conversation
Elena-Bruyako
left a comment
There was a problem hiding this comment.
fix CI/CD
fix checkstyle
Have you done first Create repo HW?
see comments
| return bookService.getBookById(id); | ||
| } | ||
| @PostMapping | ||
| public BookDto createBook(@RequestBody CreateBookRequestDto bookDto) { | ||
| return bookService.createBook(bookDto); |
There was a problem hiding this comment.
| return bookService.getBookById(id); | |
| } | |
| @PostMapping | |
| public BookDto createBook(@RequestBody CreateBookRequestDto bookDto) { | |
| return bookService.createBook(bookDto); | |
| return bookService.getBookById(id); | |
| } | |
| @PostMapping | |
| public BookDto createBook(@RequestBody CreateBookRequestDto bookDto) { | |
| return bookService.createBook(bookDto); |
| public BookDto getBookById(@PathVariable Long id) { | ||
| return bookService.getBookById(id); | ||
| } | ||
| @PostMapping |
|
|
||
| @Entity | ||
| @Table(name = "books") | ||
| @Data |
There was a problem hiding this comment.
don't use @Data for entities
| @Data | |
| @Getter | |
| @Setter |
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
| private String title; |
| import org.example.springbootweb.model.Book; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface BookRepository extends JpaRepository<Book, Long> { |
There was a problem hiding this comment.
you should implement logic by using Session and Transaction
| BookDto createBook(CreateBookRequestDto bookDto); | ||
| List<BookDto> getAll(); | ||
| BookDto getBookById(Long id); |
There was a problem hiding this comment.
| BookDto createBook(CreateBookRequestDto bookDto); | |
| List<BookDto> getAll(); | |
| BookDto getBookById(Long id); | |
| BookDto createBook(CreateBookRequestDto bookDto); | |
| List<BookDto> getAll(); | |
| BookDto getBookById(Long id); |
| spring.datasource.password=password | ||
| spring.jpa.database-platform=org.hibernate.dialect.H2Dialect | ||
| spring.jpa.show-sql=true | ||
| spring.jpa.hibernate.ddl-auto=update |
There was a problem hiding this comment.
| spring.jpa.hibernate.ddl-auto=update | |
| spring.jpa.hibernate.ddl-auto=create-drop |
| @@ -0,0 +1,7 @@ | |||
| spring.datasource.url=jdbc:h2:mem:testdb | |||
There was a problem hiding this comment.
h2 is used only for test purposes
| } | ||
|
|
||
| @PostMapping | ||
| @ResponseStatus(HttpStatus.CREATED) // Add status 201 |
There was a problem hiding this comment.
| @ResponseStatus(HttpStatus.CREATED) // Add status 201 | |
| @ResponseStatus(HttpStatus.CREATED) |
| Book save(Book book); | ||
| List<Book> findAll(); | ||
| Optional<Book> findById(Long id); |
There was a problem hiding this comment.
add emtpy lines between methods
check your checkstyle (looks like don't work properly)
| @@ -0,0 +1,8 @@ | |||
| <?xml version="1.0"?> | |||
There was a problem hiding this comment.
this is wrong file
come back to the first HW (Create repo) and find correct version of the checkstyle file
if you have some issues - ask in chat
Elena-Bruyako
left a comment
There was a problem hiding this comment.
Please, open Spring Boot Intro lesson -> Create a Repo and read requirements

Aslo, fix CI/CD
See this section in Create a Repo task
Create a .github directory (pay attention to the folder name, it should start with . (dot)) in your project root directory. Inside this directory create a new directory workflows. (as an example please see [this project's](https://github.com/mate-academy/hibernate-relations-hw) structure)
Inside the workflows directory create a new file ci.yml and paste this code into it:
name: Java CI
on:
- push
- pull_request
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify
| @@ -0,0 +1,22 @@ | |||
| <?xml version="1.0"?> | |||
| <!DOCTYPE module PUBLIC | |||
No description provided.