forked from springframeworkguru/spring5webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from azermirzayev/lesson/lesson_21_configuring_…
…mwc_controller Add parent on pom
- Loading branch information
Showing
5 changed files
with
66 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/guru/springframework/spring5webapp/controller/BookController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package guru.springframework.spring5webapp.controller; | ||
|
||
import guru.springframework.spring5webapp.repositories.BookRepository; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
@Controller | ||
public class BookController { | ||
|
||
private final BookRepository bookRepository; | ||
|
||
public BookController(BookRepository bookRepository) { | ||
this.bookRepository = bookRepository; | ||
} | ||
|
||
@RequestMapping("/books") | ||
public String getBooks(Model model){ | ||
|
||
model.addAttribute("books", bookRepository.findAll()); | ||
return "books"; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/guru/springframework/spring5webapp/repositories/PublisherRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package guru.springframework.spring5webapp.repositories; | ||
|
||
import guru.springframework.spring5webapp.domain.Publisher; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface PublisherRepository extends CrudRepository<Publisher, Long> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
spring.h2.console.enabled=true |