From a6b215d7a35c293f0c4fdd6ff556ed457c890221 Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 14 Mar 2021 08:38:24 +0530 Subject: [PATCH 1/3] BAEL-4810 Spring Boot with JSP initial sample commit --- spring-web-modules/pom.xml | 1 + spring-web-modules/spring-boot-jsp/README.md | 6 ++ spring-web-modules/spring-boot-jsp/pom.xml | 86 +++++++++++++++++++ .../boot/jsp/SpringBootJspApplication.java | 19 ++++ .../boot/jsp/SpringBootJspConfiguration.java | 30 +++++++ .../boot/jsp/controller/BookController.java | 45 ++++++++++ .../java/com/baeldung/boot/jsp/dto/Book.java | 14 +++ .../jsp/exception/DuplicateBookException.java | 13 +++ .../exception/LibraryControllerAdvice.java | 19 ++++ .../boot/jsp/repository/BookRepository.java | 14 +++ .../impl/InMemoryBookRepository.java | 36 ++++++++ .../boot/jsp/repository/model/BookData.java | 16 ++++ .../boot/jsp/service/BookService.java | 11 +++ .../jsp/service/impl/BookServiceImpl.java | 50 +++++++++++ .../src/main/resources/application.properties | 4 + .../src/main/resources/static/css/common.css | 10 +++ .../src/main/resources/static/error/4xx.html | 10 +++ .../src/main/webapp/WEB-INF/jsp/add-book.jsp | 23 +++++ .../main/webapp/WEB-INF/jsp/error-book.jsp | 18 ++++ .../main/webapp/WEB-INF/jsp/view-books.jsp | 30 +++++++ 20 files changed, 455 insertions(+) create mode 100644 spring-web-modules/spring-boot-jsp/README.md create mode 100644 spring-web-modules/spring-boot-jsp/pom.xml create mode 100644 spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspApplication.java create mode 100644 spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspConfiguration.java create mode 100644 spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/controller/BookController.java create mode 100644 spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/dto/Book.java create mode 100644 spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/exception/DuplicateBookException.java create mode 100644 spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/exception/LibraryControllerAdvice.java create mode 100644 spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/repository/BookRepository.java create mode 100644 spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/repository/impl/InMemoryBookRepository.java create mode 100644 spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/repository/model/BookData.java create mode 100644 spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/service/BookService.java create mode 100644 spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/service/impl/BookServiceImpl.java create mode 100644 spring-web-modules/spring-boot-jsp/src/main/resources/application.properties create mode 100644 spring-web-modules/spring-boot-jsp/src/main/resources/static/css/common.css create mode 100644 spring-web-modules/spring-boot-jsp/src/main/resources/static/error/4xx.html create mode 100644 spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/add-book.jsp create mode 100644 spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/error-book.jsp create mode 100644 spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/view-books.jsp diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index 37ee84da25..ca96dcff35 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -41,6 +41,7 @@ spring-thymeleaf spring-thymeleaf-2 spring-thymeleaf-3 + spring-boot-jsp diff --git a/spring-web-modules/spring-boot-jsp/README.md b/spring-web-modules/spring-boot-jsp/README.md new file mode 100644 index 0000000000..8242461917 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/README.md @@ -0,0 +1,6 @@ +## Spring MVC Forms JSP + +This module contains articles about Spring Boot used with JSP + +### Relevant Articles +- [Spring Boot with JSP](https://www.baeldung.com/?) diff --git a/spring-web-modules/spring-boot-jsp/pom.xml b/spring-web-modules/spring-boot-jsp/pom.xml new file mode 100644 index 0000000000..1599f4aa34 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/pom.xml @@ -0,0 +1,86 @@ + + + 4.0.0 + + com.baeldung + spring-boot-jsp + 0.0.1-SNAPSHOT + spring-boot-jsp + war + + + com.baeldung + spring-web-modules + 0.0.1-SNAPSHOT + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + javax.servlet + jstl + ${jstl.version} + + + org.apache.tomcat.embed + tomcat-embed-jasper + + + + + org.projectlombok + lombok + ${lombok.version} + provided + + + org.springframework.boot + spring-boot-starter-web + + + + + + + + + + + spring-boot-jsp + + + org.springframework.boot + spring-boot-maven-plugin + + com.baeldung.boot.jsp.SpringBootJspApplication + + + + + repackage + + + + + + + + + 1.2 + 2.4.0 + + + \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspApplication.java b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspApplication.java new file mode 100644 index 0000000000..c77554f9f6 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspApplication.java @@ -0,0 +1,19 @@ +package com.baeldung.boot.jsp; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +@SpringBootApplication(scanBasePackages = "com.baeldung.boot.jsp") +public class SpringBootJspApplication extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { + return builder.sources(SpringBootJspApplication.class); + } + + public static void main(String[] args) { + SpringApplication.run(SpringBootJspApplication.class); + } +} \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspConfiguration.java b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspConfiguration.java new file mode 100644 index 0000000000..83847a40a3 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspConfiguration.java @@ -0,0 +1,30 @@ +package com.baeldung.boot.jsp; + +import java.util.HashMap; +import java.util.Map; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +import com.baeldung.boot.jsp.repository.BookRepository; +import com.baeldung.boot.jsp.repository.impl.InMemoryBookRepository; +import com.baeldung.boot.jsp.repository.model.BookData; + +@Configuration +@ComponentScan(basePackages = "com.baeldung.boot.jsp") +public class SpringBootJspConfiguration { + + @Bean + public BookRepository provideBookRepository() { + return new InMemoryBookRepository(initialBookData()); + } + + private static Map initialBookData() { + Map initData = new HashMap<>(); + initData.put("ISBN-TEST-1", new BookData("ISBN-TEST-1", "Book 1", "Book 1 Author")); + initData.put("ISBN-TEST-2", new BookData("ISBN-TEST-2", "Book 2", "Book 2 Author")); + initData.put("ISBN-TEST-3", new BookData("ISBN-TEST-3", "Book 3", "Book 3 Author")); + return initData; + } +} \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/controller/BookController.java b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/controller/BookController.java new file mode 100644 index 0000000000..c104a9cad3 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/controller/BookController.java @@ -0,0 +1,45 @@ +package com.baeldung.boot.jsp.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; +import org.springframework.web.servlet.view.RedirectView; + +import com.baeldung.boot.jsp.dto.Book; +import com.baeldung.boot.jsp.service.BookService; + +@Controller +@RequestMapping("/book") +public class BookController { + + private final BookService bookService; + + public BookController(BookService bookService) { + this.bookService = bookService; + } + + @GetMapping("/viewBooks") + public String viewBooks(Model model) { + model.addAttribute("books", bookService.getBooks()); + return "view-books"; + } + + @GetMapping("/addBook") + public String addBookView(Model model) { + model.addAttribute("book", new Book()); + return "add-book"; + } + + @PostMapping("/addBook") + public RedirectView addBook(@ModelAttribute("book") Book book, RedirectAttributes redirectAttributes) { + final RedirectView redirectView = new RedirectView("/book/addBook", true); + Book savedBook = bookService.addBook(book); + redirectAttributes.addFlashAttribute("savedBook", savedBook); + redirectAttributes.addFlashAttribute("addBookSuccess", true); + return redirectView; + } +} \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/dto/Book.java b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/dto/Book.java new file mode 100644 index 0000000000..f4cd6b0b3b --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/dto/Book.java @@ -0,0 +1,14 @@ +package com.baeldung.boot.jsp.dto; + +import lombok.*; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@ToString +public class Book { + private String isbn; + private String name; + private String author; +} \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/exception/DuplicateBookException.java b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/exception/DuplicateBookException.java new file mode 100644 index 0000000000..bd52a591e3 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/exception/DuplicateBookException.java @@ -0,0 +1,13 @@ +package com.baeldung.boot.jsp.exception; + +import com.baeldung.boot.jsp.dto.Book; +import lombok.Getter; + +@Getter +public class DuplicateBookException extends RuntimeException { + private final Book book; + + public DuplicateBookException(Book book) { + this.book = book; + } +} \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/exception/LibraryControllerAdvice.java b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/exception/LibraryControllerAdvice.java new file mode 100644 index 0000000000..8217fea2e3 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/exception/LibraryControllerAdvice.java @@ -0,0 +1,19 @@ +package com.baeldung.boot.jsp.exception; + +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.servlet.ModelAndView; + +@ControllerAdvice +public class LibraryControllerAdvice { + + @ExceptionHandler(value = DuplicateBookException.class) + public ModelAndView duplicateBookException(DuplicateBookException e) { + final ModelAndView modelAndView = new ModelAndView(); + modelAndView.addObject("ref", e.getBook().getIsbn()); + modelAndView.addObject("object", e.getBook()); + modelAndView.addObject("message", "Cannot add an already existing book"); + modelAndView.setViewName("error-book"); + return modelAndView; + } +} \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/repository/BookRepository.java b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/repository/BookRepository.java new file mode 100644 index 0000000000..f10cecfa81 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/repository/BookRepository.java @@ -0,0 +1,14 @@ +package com.baeldung.boot.jsp.repository; + +import java.util.Collection; +import java.util.Optional; + +import com.baeldung.boot.jsp.repository.model.BookData; + +public interface BookRepository { + Collection findAll(); + + Optional findById(String isbn); + + BookData add(BookData book); +} diff --git a/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/repository/impl/InMemoryBookRepository.java b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/repository/impl/InMemoryBookRepository.java new file mode 100644 index 0000000000..8fae303158 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/repository/impl/InMemoryBookRepository.java @@ -0,0 +1,36 @@ +package com.baeldung.boot.jsp.repository.impl; + +import java.util.*; + +import com.baeldung.boot.jsp.repository.BookRepository; +import com.baeldung.boot.jsp.repository.model.BookData; + +public class InMemoryBookRepository implements BookRepository { + + private final Map storedBooks; + + public InMemoryBookRepository(Map storedBooks) { + this.storedBooks = new HashMap<>(); + this.storedBooks.putAll(storedBooks); + } + + @Override + public Collection findAll() { + if (storedBooks.isEmpty()) { + return Collections.emptyList(); + } + + return storedBooks.values(); + } + + @Override + public Optional findById(String isbn) { + return Optional.ofNullable(storedBooks.get(isbn)); + } + + @Override + public BookData add(BookData book) { + storedBooks.put(book.getIsbn(), book); + return book; + } +} diff --git a/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/repository/model/BookData.java b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/repository/model/BookData.java new file mode 100644 index 0000000000..7c722a92e5 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/repository/model/BookData.java @@ -0,0 +1,16 @@ +package com.baeldung.boot.jsp.repository.model; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class BookData { + private String isbn; + private String name; + private String author; +} \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/service/BookService.java b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/service/BookService.java new file mode 100644 index 0000000000..7c2c401ef2 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/service/BookService.java @@ -0,0 +1,11 @@ +package com.baeldung.boot.jsp.service; + +import java.util.Collection; + +import com.baeldung.boot.jsp.dto.Book; + +public interface BookService { + Collection getBooks(); + + Book addBook(Book book); +} \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/service/impl/BookServiceImpl.java b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/service/impl/BookServiceImpl.java new file mode 100644 index 0000000000..519ee19205 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/service/impl/BookServiceImpl.java @@ -0,0 +1,50 @@ +package com.baeldung.boot.jsp.service.impl; + +import java.util.Collection; +import java.util.Optional; +import java.util.stream.Collectors; + +import com.baeldung.boot.jsp.exception.DuplicateBookException; +import org.springframework.stereotype.Service; + +import com.baeldung.boot.jsp.dto.Book; +import com.baeldung.boot.jsp.repository.BookRepository; +import com.baeldung.boot.jsp.repository.model.BookData; +import com.baeldung.boot.jsp.service.BookService; + +@Service +public class BookServiceImpl implements BookService { + + private final BookRepository bookRepository; + + public BookServiceImpl(BookRepository bookRepository) { + this.bookRepository = bookRepository; + } + + @Override + public Collection getBooks() { + return bookRepository.findAll() + .stream() + .map(BookServiceImpl::convertBookData) + .collect(Collectors.toList()); + } + + @Override + public Book addBook(Book book) { + final Optional existingBook = bookRepository.findById(book.getIsbn()); + if (existingBook.isPresent()) { + throw new DuplicateBookException(book); + } + + final BookData savedBook = bookRepository.add(convertBook(book)); + return convertBookData(savedBook); + } + + private static Book convertBookData(BookData bookData) { + return new Book(bookData.getIsbn(), bookData.getName(), bookData.getAuthor()); + } + + private static BookData convertBook(Book book) { + return new BookData(book.getIsbn(), book.getName(), book.getAuthor()); + } +} diff --git a/spring-web-modules/spring-boot-jsp/src/main/resources/application.properties b/spring-web-modules/spring-boot-jsp/src/main/resources/application.properties new file mode 100644 index 0000000000..56638f8c1a --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/resources/application.properties @@ -0,0 +1,4 @@ +server.servlet.context-path=/spring-boot-jsp + +spring.mvc.view.prefix: /WEB-INF/jsp/ +spring.mvc.view.suffix: .jsp \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/resources/static/css/common.css b/spring-web-modules/spring-boot-jsp/src/main/resources/static/css/common.css new file mode 100644 index 0000000000..a32d81c6a2 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/resources/static/css/common.css @@ -0,0 +1,10 @@ +table { + font-family: arial, sans-serif; + border-collapse: collapse; +} + +td, th { + border: 1px solid #dddddd; + text-align: left; + padding: 8px; +} \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/resources/static/error/4xx.html b/spring-web-modules/spring-boot-jsp/src/main/resources/static/error/4xx.html new file mode 100644 index 0000000000..c27bd8bb7a --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/resources/static/error/4xx.html @@ -0,0 +1,10 @@ + + + + + Error + + +Opps! 4xx Error Occurred. + + \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/add-book.jsp b/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/add-book.jsp new file mode 100644 index 0000000000..3b815dfafb --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/add-book.jsp @@ -0,0 +1,23 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Add Book + + + + +
Successfully added Book with ISBN: ${savedBook.isbn}
+
+ + + + ISBN: + Book Name: + Author Name: + + + + + \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/error-book.jsp b/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/error-book.jsp new file mode 100644 index 0000000000..c04756462d --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/error-book.jsp @@ -0,0 +1,18 @@ +<%-- + Created by IntelliJ IDEA. + User: jason + Date: 3/13/21 + Time: 10:39 PM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Error + + +

Reference: ${ref}

+

Error Message: ${message}

+

Object: ${object}

+ + diff --git a/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/view-books.jsp b/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/view-books.jsp new file mode 100644 index 0000000000..46bfbbac99 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/view-books.jsp @@ -0,0 +1,30 @@ +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + View Books + + " rel="stylesheet" type="text/css"> + + + + + + + + + + + + + + + + + + + + +
ISBNNameAuthor
${book.isbn}${book.name}${book.author}
+ + \ No newline at end of file From c5e0771e1de17e1037c6cb9bca2bb6271f84a92e Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 21 Mar 2021 10:23:56 +0530 Subject: [PATCH 2/3] BAEL-4810: First Review Improvements. Added test cases and fixed some indentations --- spring-web-modules/spring-boot-jsp/pom.xml | 24 ++++- .../boot/jsp/SpringBootJspConfiguration.java | 9 +- .../src/main/webapp/WEB-INF/jsp/add-book.jsp | 32 +++---- .../main/webapp/WEB-INF/jsp/error-book.jsp | 16 ++-- .../main/webapp/WEB-INF/jsp/view-books.jsp | 46 +++++---- .../BookControllerIntegrationTest.java | 93 +++++++++++++++++++ .../controller/BookControllerUnitTest.java | 76 +++++++++++++++ .../impl/InMemoryBookRepositoryUnitTest.java | 62 +++++++++++++ .../service/BookServiceIntegrationTest.java | 84 +++++++++++++++++ .../service/impl/BookServiceImplUnitTest.java | 75 +++++++++++++++ 10 files changed, 460 insertions(+), 57 deletions(-) create mode 100644 spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/controller/BookControllerIntegrationTest.java create mode 100644 spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/controller/BookControllerUnitTest.java create mode 100644 spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/repository/impl/InMemoryBookRepositoryUnitTest.java create mode 100644 spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/service/BookServiceIntegrationTest.java create mode 100644 spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/service/impl/BookServiceImplUnitTest.java diff --git a/spring-web-modules/spring-boot-jsp/pom.xml b/spring-web-modules/spring-boot-jsp/pom.xml index 1599f4aa34..672cc8b426 100644 --- a/spring-web-modules/spring-boot-jsp/pom.xml +++ b/spring-web-modules/spring-boot-jsp/pom.xml @@ -37,7 +37,7 @@ org.apache.tomcat.embed tomcat-embed-jasper - + @@ -50,12 +50,29 @@ org.springframework.boot spring-boot-starter-web - + + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter.version} + test + + + org.mockito + mockito-core + ${mockito.version} + test + + + org.springframework.boot + spring-boot-starter-test + test + @@ -80,7 +97,8 @@ 1.2 - 2.4.0 + 5.7.1 + 2.4.4 \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspConfiguration.java b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspConfiguration.java index 83847a40a3..7fdae2c2a6 100644 --- a/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspConfiguration.java +++ b/spring-web-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspConfiguration.java @@ -3,8 +3,8 @@ package com.baeldung.boot.jsp; import java.util.HashMap; import java.util.Map; +import org.springframework.boot.SpringBootConfiguration; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import com.baeldung.boot.jsp.repository.BookRepository; @@ -12,7 +12,6 @@ import com.baeldung.boot.jsp.repository.impl.InMemoryBookRepository; import com.baeldung.boot.jsp.repository.model.BookData; @Configuration -@ComponentScan(basePackages = "com.baeldung.boot.jsp") public class SpringBootJspConfiguration { @Bean @@ -22,9 +21,9 @@ public class SpringBootJspConfiguration { private static Map initialBookData() { Map initData = new HashMap<>(); - initData.put("ISBN-TEST-1", new BookData("ISBN-TEST-1", "Book 1", "Book 1 Author")); - initData.put("ISBN-TEST-2", new BookData("ISBN-TEST-2", "Book 2", "Book 2 Author")); - initData.put("ISBN-TEST-3", new BookData("ISBN-TEST-3", "Book 3", "Book 3 Author")); + initData.put("ISBN-1", new BookData("ISBN-1", "Book 1", "Book 1 Author")); + initData.put("ISBN-2", new BookData("ISBN-2", "Book 2", "Book 2 Author")); + initData.put("ISBN-3", new BookData("ISBN-3", "Book 3", "Book 3 Author")); return initData; } } \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/add-book.jsp b/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/add-book.jsp index 3b815dfafb..8195743da8 100644 --- a/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/add-book.jsp +++ b/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/add-book.jsp @@ -2,22 +2,20 @@ <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> - - Add Book - - + + Add Book + + + +
Successfully added Book with ISBN: ${savedBook.isbn}
+
- -
Successfully added Book with ISBN: ${savedBook.isbn}
-
- - - - ISBN: - Book Name: - Author Name: - - - - + + + ISBN: + Book Name: + Author Name: + + + \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/error-book.jsp b/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/error-book.jsp index c04756462d..6db90ca5c7 100644 --- a/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/error-book.jsp +++ b/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/error-book.jsp @@ -7,12 +7,12 @@ --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> - - Error - - -

Reference: ${ref}

-

Error Message: ${message}

-

Object: ${object}

- + + Error + + +

Reference: ${ref}

+

Error Message: ${message}

+

Object: ${object}

+ diff --git a/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/view-books.jsp b/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/view-books.jsp index 46bfbbac99..4a8e00a69b 100644 --- a/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/view-books.jsp +++ b/spring-web-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/view-books.jsp @@ -1,30 +1,28 @@ <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> - - View Books - - " rel="stylesheet" type="text/css"> - - - - - - - - - - - - - + + View Books + " rel="stylesheet" type="text/css"> + + +
ISBNNameAuthor
+ - - - + + + - - -
${book.isbn}${book.name}${book.author}ISBNNameAuthor
- + + + + + ${book.isbn} + ${book.name} + ${book.author} + + + + + \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/controller/BookControllerIntegrationTest.java b/spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/controller/BookControllerIntegrationTest.java new file mode 100644 index 0000000000..1847cbf545 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/controller/BookControllerIntegrationTest.java @@ -0,0 +1,93 @@ +package com.baeldung.boot.jsp.controller; + +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasProperty; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; + +import java.util.Collections; +import java.util.Optional; + +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import com.baeldung.boot.jsp.repository.BookRepository; +import com.baeldung.boot.jsp.repository.impl.InMemoryBookRepository; +import com.baeldung.boot.jsp.repository.model.BookData; + +@ExtendWith(SpringExtension.class) +@WebAppConfiguration +@ContextConfiguration +@AutoConfigureMockMvc +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +public class BookControllerIntegrationTest { + + @Autowired + private MockMvc mockMvc; + + @Autowired + private BookRepository bookRepository; + + @Test + @Order(1) + public void whenAddBook_thenBookSaved() throws Exception { + MockHttpServletRequestBuilder addBookRequest = MockMvcRequestBuilders.post("/book/addBook") + .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE) + .param("isbn", "isbn1") + .param("name", "name1") + .param("author", "author1"); + mockMvc.perform(addBookRequest) + .andReturn(); + + Optional storedBookOpt = bookRepository.findById("isbn1"); + assertTrue(storedBookOpt.isPresent()); + assertEquals("name1", storedBookOpt.get() + .getName()); + assertEquals("author1", storedBookOpt.get() + .getAuthor()); + } + + @Test + @Order(2) + public void givenAlreadyExistingBook_whenAddBook_thenShowErrorPage() throws Exception { + MockHttpServletRequestBuilder addBookRequest = MockMvcRequestBuilders.post("/book/addBook") + .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE) + .param("isbn", "isbn1") + .param("name", "name1") + .param("author", "author1"); + ResultActions addBookResult = mockMvc.perform(addBookRequest); + + addBookResult.andExpect(view().name("error-book")) + .andExpect(model().attribute("ref", "isbn1")) + .andExpect(model().attribute("object", hasProperty("isbn", equalTo("isbn1")))) + .andExpect(model().attribute("message", "Cannot add an already existing book")); + } + + @Configuration + @ComponentScan("com.baeldung.boot.jsp") + static class ContextConfiguration { + + @Bean + public BookRepository provideBookRepository() { + return new InMemoryBookRepository(Collections.emptyMap()); + } + } +} \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/controller/BookControllerUnitTest.java b/spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/controller/BookControllerUnitTest.java new file mode 100644 index 0000000000..af1d3d4956 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/controller/BookControllerUnitTest.java @@ -0,0 +1,76 @@ +package com.baeldung.boot.jsp.controller; + +import static org.hamcrest.Matchers.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.junit.jupiter.api.Test; +import org.mockito.AdditionalAnswers; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import com.baeldung.boot.jsp.dto.Book; +import com.baeldung.boot.jsp.service.BookService; + +@WebMvcTest(BookController.class) +class BookControllerUnitTest { + + @Autowired + private MockMvc mockMvc; + + @MockBean + private BookService bookService; + + @Test + public void whenViewBooks_thenReturnBooksView() throws Exception { + when(bookService.getBooks()).thenReturn(existingBooks()); + ResultActions viewBooksResult = mockMvc.perform(get("/book/viewBooks")); + + viewBooksResult.andExpect(view().name("view-books")) + .andExpect(model().attribute("books", hasSize(3))); + } + + @Test + public void whenAddBookView_thenReturnAddBooksView() throws Exception { + ResultActions addBookViewResult = mockMvc.perform(get("/book/addBook")); + + addBookViewResult.andExpect(view().name("add-book")) + .andExpect(model().attribute("book", isA(Book.class))); + } + + @Test + public void whenAddBookPost_thenRedirectToAddBookView() throws Exception { + when(bookService.addBook(any(Book.class))).thenAnswer(AdditionalAnswers.returnsFirstArg()); + MockHttpServletRequestBuilder addBookRequest = MockMvcRequestBuilders.post("/book/addBook") + .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE) + .param("isbn", "isbn1") + .param("name", "name1") + .param("author", "author1"); + ResultActions addBookResult = mockMvc.perform(addBookRequest); + + addBookResult.andExpect(status().is3xxRedirection()) + .andExpect(redirectedUrl("/book/addBook")) + .andExpect(flash().attribute("savedBook", hasProperty("isbn", equalTo("isbn1")))) + .andExpect(flash().attribute("addBookSuccess", true)); + } + + private static Collection existingBooks() { + List books = new ArrayList<>(); + books.add(new Book("isbn1", "name1", "author1")); + books.add(new Book("isbn2", "name2", "author2")); + books.add(new Book("isbn3", "name3", "author3")); + return books; + } +} \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/repository/impl/InMemoryBookRepositoryUnitTest.java b/spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/repository/impl/InMemoryBookRepositoryUnitTest.java new file mode 100644 index 0000000000..83f0c19e26 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/repository/impl/InMemoryBookRepositoryUnitTest.java @@ -0,0 +1,62 @@ +package com.baeldung.boot.jsp.repository.impl; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.*; + +import org.junit.jupiter.api.Test; + +import com.baeldung.boot.jsp.repository.BookRepository; +import com.baeldung.boot.jsp.repository.model.BookData; + +public class InMemoryBookRepositoryUnitTest { + + @Test + public void givenEmtpyData_whenFindAll_thenReturnEmptyCollection() { + BookRepository bookRepository = new InMemoryBookRepository(Collections.emptyMap()); + Collection storedBooks = bookRepository.findAll(); + + assertEquals(0, storedBooks.size()); + } + + @Test + public void givenInitialData_whenFindAll_thenReturnInitialData() { + BookRepository bookRepository = new InMemoryBookRepository(initialBookData()); + Collection storedBooks = bookRepository.findAll(); + + assertEquals(3, storedBooks.size()); + } + + @Test + public void givenInitialData_whenFindUnavailableIsbn_thenReturnEmpty() { + BookRepository bookRepository = new InMemoryBookRepository(initialBookData()); + Optional storedBookOpt = bookRepository.findById("isbn4"); + + assertFalse(storedBookOpt.isPresent()); + } + + @Test + public void givenInitialData_whenFindAvailableIsbn_thenReturnItem() { + BookRepository bookRepository = new InMemoryBookRepository(initialBookData()); + Optional storedBookOpt = bookRepository.findById("isbn1"); + + assertTrue(storedBookOpt.isPresent()); + } + + @Test + public void givenAddedIsbn_whenFindAvailableIsbn_thenReturnItem() { + BookRepository bookRepository = new InMemoryBookRepository(Collections.emptyMap()); + bookRepository.add(new BookData("isbn4", "name4", "author4")); + Optional storedBookOpt = bookRepository.findById("isbn4"); + + assertTrue(storedBookOpt.isPresent()); + } + + private static Map initialBookData() { + Map initData = new HashMap<>(); + initData.put("isbn1", new BookData("isbn1", "name1", "author1")); + initData.put("isbn2", new BookData("isbn2", "name2", "author2")); + initData.put("isbn3", new BookData("isbn3", "name3", "author3")); + return initData; + } +} \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/service/BookServiceIntegrationTest.java b/spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/service/BookServiceIntegrationTest.java new file mode 100644 index 0000000000..4223f3f970 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/service/BookServiceIntegrationTest.java @@ -0,0 +1,84 @@ +package com.baeldung.boot.jsp.service; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.baeldung.boot.jsp.dto.Book; +import com.baeldung.boot.jsp.exception.DuplicateBookException; +import com.baeldung.boot.jsp.repository.BookRepository; +import com.baeldung.boot.jsp.repository.impl.InMemoryBookRepository; +import com.baeldung.boot.jsp.repository.model.BookData; + +@ExtendWith(SpringExtension.class) +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +@ContextConfiguration(loader = AnnotationConfigContextLoader.class) +public class BookServiceIntegrationTest { + + @Autowired + private BookService bookService; + + @Test + @Order(1) + public void givenNoAddedBooks_whenGetAllBooks_thenReturnInitialBooks() { + Collection storedBooks = bookService.getBooks(); + + assertEquals(3, storedBooks.size()); + assertThat(storedBooks, hasItem(hasProperty("isbn", equalTo("ISBN-TEST-1")))); + assertThat(storedBooks, hasItem(hasProperty("isbn", equalTo("ISBN-TEST-2")))); + assertThat(storedBooks, hasItem(hasProperty("isbn", equalTo("ISBN-TEST-3")))); + } + + @Test + @Order(2) + public void givenBookNotAlreadyExists_whenAddBook_thenReturnSuccessfully() { + Book bookToBeAdded = new Book("ISBN-ADD-TEST-4", "Added Book 4", "Added Book 4 Author"); + Book storedBook = bookService.addBook(bookToBeAdded); + + assertEquals(bookToBeAdded.getIsbn(), storedBook.getIsbn()); + } + + @Test + @Order(3) + public void givenBookAlreadyExists_whenAddBook_thenDuplicateBookException() { + Book bookToBeAdded = new Book("ISBN-ADD-TEST-4", "Updated Book 4", "Updated Book 4 Author"); + + assertThrows(DuplicateBookException.class, () -> bookService.addBook(bookToBeAdded)); + } + + @Configuration + @ComponentScan("com.baeldung.boot.jsp") + static class ContextConfiguration { + + @Bean + public BookRepository provideBookRepository() { + return new InMemoryBookRepository(initialBookData()); + } + + private static Map initialBookData() { + Map initData = new HashMap<>(); + initData.put("ISBN-TEST-1", new BookData("ISBN-TEST-1", "Book 1", "Book 1 Author")); + initData.put("ISBN-TEST-2", new BookData("ISBN-TEST-2", "Book 2", "Book 2 Author")); + initData.put("ISBN-TEST-3", new BookData("ISBN-TEST-3", "Book 3", "Book 3 Author")); + return initData; + } + } +} \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/service/impl/BookServiceImplUnitTest.java b/spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/service/impl/BookServiceImplUnitTest.java new file mode 100644 index 0000000000..defbf71fd9 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/test/java/com/baeldung/boot/jsp/service/impl/BookServiceImplUnitTest.java @@ -0,0 +1,75 @@ +package com.baeldung.boot.jsp.service.impl; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Optional; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.AdditionalAnswers; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.baeldung.boot.jsp.dto.Book; +import com.baeldung.boot.jsp.exception.DuplicateBookException; +import com.baeldung.boot.jsp.repository.BookRepository; +import com.baeldung.boot.jsp.repository.model.BookData; +import com.baeldung.boot.jsp.service.BookService; + +@ExtendWith(MockitoExtension.class) +public class BookServiceImplUnitTest { + + @Mock + private BookRepository bookRepository; + + @Test + public void whenGetBooks_thenAllBooksReturned() { + when(bookRepository.findAll()).thenReturn(existingBooks()); + BookService bookService = new BookServiceImpl(bookRepository); + + Collection storedBooks = bookService.getBooks(); + assertEquals(3, storedBooks.size()); + assertThat(storedBooks, hasItem(hasProperty("isbn", equalTo("isbn1")))); + assertThat(storedBooks, hasItem(hasProperty("isbn", equalTo("isbn2")))); + assertThat(storedBooks, hasItem(hasProperty("isbn", equalTo("isbn3")))); + } + + @Test + public void whenAddBook_thenAddSuccessful() { + when(bookRepository.findById(anyString())).thenReturn(Optional.empty()); + when(bookRepository.add(any(BookData.class))).thenAnswer(AdditionalAnswers.returnsFirstArg()); + BookService bookService = new BookServiceImpl(bookRepository); + Book book = bookService.addBook(new Book("isbn1", "name1", "author1")); + + assertEquals("isbn1", book.getIsbn()); + assertEquals("name1", book.getName()); + assertEquals("author1", book.getAuthor()); + } + + @Test + public void givenBookAlreadyExist_whenAddBook_thenDuplicateBookException() { + BookData existingBook = new BookData("isbn1", "name1", "author1"); + when(bookRepository.findById("isbn1")).thenReturn(Optional.of(existingBook)); + BookService bookService = new BookServiceImpl(bookRepository); + Book bookToBeAdded = new Book("isbn1", "name1", "author1"); + + assertThrows(DuplicateBookException.class, () -> bookService.addBook(bookToBeAdded)); + } + + private static Collection existingBooks() { + List books = new ArrayList<>(); + books.add(new BookData("isbn1", "name1", "author1")); + books.add(new BookData("isbn2", "name2", "author2")); + books.add(new BookData("isbn3", "name3", "author3")); + return books; + } +} \ No newline at end of file From 4c1b4723e02fd6019e7ee6ebe4368e9b708fb8cc Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 22 Mar 2021 21:00:53 +0530 Subject: [PATCH 3/3] BAEL-4810: Second Review Improvements. Fixed some pom warnings and dependencies. Removed incorrectly added Readme.md --- spring-web-modules/spring-boot-jsp/README.md | 6 ------ spring-web-modules/spring-boot-jsp/pom.xml | 15 +-------------- 2 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 spring-web-modules/spring-boot-jsp/README.md diff --git a/spring-web-modules/spring-boot-jsp/README.md b/spring-web-modules/spring-boot-jsp/README.md deleted file mode 100644 index 8242461917..0000000000 --- a/spring-web-modules/spring-boot-jsp/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## Spring MVC Forms JSP - -This module contains articles about Spring Boot used with JSP - -### Relevant Articles -- [Spring Boot with JSP](https://www.baeldung.com/?) diff --git a/spring-web-modules/spring-boot-jsp/pom.xml b/spring-web-modules/spring-boot-jsp/pom.xml index 672cc8b426..d646b6058a 100644 --- a/spring-web-modules/spring-boot-jsp/pom.xml +++ b/spring-web-modules/spring-boot-jsp/pom.xml @@ -3,8 +3,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - - com.baeldung spring-boot-jsp 0.0.1-SNAPSHOT spring-boot-jsp @@ -56,18 +54,6 @@ - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - org.mockito - mockito-core - ${mockito.version} - test - org.springframework.boot spring-boot-starter-test @@ -81,6 +67,7 @@ org.springframework.boot spring-boot-maven-plugin + ${spring-boot.version} com.baeldung.boot.jsp.SpringBootJspApplication