From 0e55fdd05b25778785c7d1b78dd9cdd392a6a6ef Mon Sep 17 00:00:00 2001 From: Eric Goebelbecker Date: Thu, 31 May 2018 14:41:03 -0400 Subject: [PATCH] BAEL-1800 (#4378) * BAEL-1800 - Code for http://www.baeldung.com/spring-boot-starters and http://www.baeldung.com/spring-mvc-custom-data-binder * BAEL-1800 - Code for http://www.baeldung.com/maven-webjars and http://www.baeldung.com/deployable-fat-jar-spring-boot * BAEL-1800 - Code for http://www.baeldung.com/spring-boot-shutdown * BAEL-1800 - Code for http://www.baeldung.com/spring-boot-shutdown * BAEL-1800 - Code for http://www.baeldung.com/spring-boot-dependency-management-custom-parent * BAEL-1800 - updates to README * BAEL-1800 - did not need graphql and demo for webjar project. --- spring-boot-ops/README.MD | 6 ++ .../java/com/baeldung/graphql/Author.java | 31 ---------- .../java/com/baeldung/graphql/AuthorDao.java | 16 ----- .../com/baeldung/graphql/AuthorResolver.java | 17 ------ .../graphql/GraphqlConfiguration.java | 59 ------------------- .../java/com/baeldung/graphql/Mutation.java | 25 -------- .../main/java/com/baeldung/graphql/Post.java | 49 --------------- .../java/com/baeldung/graphql/PostDao.java | 24 -------- .../com/baeldung/graphql/PostResolver.java | 17 ------ .../main/java/com/baeldung/graphql/Query.java | 17 ------ .../org/baeldung/demo/DemoApplication.java | 18 ------ .../org/baeldung/demo/boottest/Employee.java | 43 -------------- .../demo/boottest/EmployeeRepository.java | 17 ------ .../demo/boottest/EmployeeRestController.java | 33 ----------- .../demo/boottest/EmployeeService.java | 16 ----- .../demo/boottest/EmployeeServiceImpl.java | 43 -------------- .../baeldung/demo/components/FooService.java | 21 ------- .../demo/exceptions/CommonException.java | 13 ---- .../demo/exceptions/FooNotFoundException.java | 13 ---- .../java/org/baeldung/demo/model/Foo.java | 45 -------------- .../demo/repository/FooRepository.java | 8 --- .../baeldung/demo/service/FooController.java | 26 -------- spring-boot/README.MD | 4 -- 23 files changed, 6 insertions(+), 555 deletions(-) delete mode 100644 spring-boot-ops/src/main/java/com/baeldung/graphql/Author.java delete mode 100644 spring-boot-ops/src/main/java/com/baeldung/graphql/AuthorDao.java delete mode 100644 spring-boot-ops/src/main/java/com/baeldung/graphql/AuthorResolver.java delete mode 100644 spring-boot-ops/src/main/java/com/baeldung/graphql/GraphqlConfiguration.java delete mode 100644 spring-boot-ops/src/main/java/com/baeldung/graphql/Mutation.java delete mode 100644 spring-boot-ops/src/main/java/com/baeldung/graphql/Post.java delete mode 100644 spring-boot-ops/src/main/java/com/baeldung/graphql/PostDao.java delete mode 100644 spring-boot-ops/src/main/java/com/baeldung/graphql/PostResolver.java delete mode 100644 spring-boot-ops/src/main/java/com/baeldung/graphql/Query.java delete mode 100644 spring-boot-ops/src/main/java/org/baeldung/demo/DemoApplication.java delete mode 100644 spring-boot-ops/src/main/java/org/baeldung/demo/boottest/Employee.java delete mode 100644 spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeRepository.java delete mode 100644 spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeRestController.java delete mode 100644 spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeService.java delete mode 100644 spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeServiceImpl.java delete mode 100644 spring-boot-ops/src/main/java/org/baeldung/demo/components/FooService.java delete mode 100644 spring-boot-ops/src/main/java/org/baeldung/demo/exceptions/CommonException.java delete mode 100644 spring-boot-ops/src/main/java/org/baeldung/demo/exceptions/FooNotFoundException.java delete mode 100644 spring-boot-ops/src/main/java/org/baeldung/demo/model/Foo.java delete mode 100644 spring-boot-ops/src/main/java/org/baeldung/demo/repository/FooRepository.java delete mode 100644 spring-boot-ops/src/main/java/org/baeldung/demo/service/FooController.java diff --git a/spring-boot-ops/README.MD b/spring-boot-ops/README.MD index e2a9a6ab59..5ac223397c 100644 --- a/spring-boot-ops/README.MD +++ b/spring-boot-ops/README.MD @@ -5,3 +5,9 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Intro to Spring Boot Starters](http://www.baeldung.com/spring-boot-starters) - [A Custom Data Binder in Spring MVC](http://www.baeldung.com/spring-mvc-custom-data-binder) +- [Introduction to WebJars](http://www.baeldung.com/maven-webjars) +- [A Quick Guide to Maven Wrapper](http://www.baeldung.com/maven-wrapper) +- [Shutdown a Spring Boot Application](http://www.baeldung.com/spring-boot-shutdown) +- [Create a Fat Jar App with Spring Boot](http://www.baeldung.com/deployable-fat-jar-spring-boot) +- [Spring Boot Dependency Management with a Custom Parent](http://www.baeldung.com/spring-boot-dependency-management-custom-parent) + diff --git a/spring-boot-ops/src/main/java/com/baeldung/graphql/Author.java b/spring-boot-ops/src/main/java/com/baeldung/graphql/Author.java deleted file mode 100644 index 11e927c564..0000000000 --- a/spring-boot-ops/src/main/java/com/baeldung/graphql/Author.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.baeldung.graphql; - -public class Author { - private String id; - private String name; - private String thumbnail; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getThumbnail() { - return thumbnail; - } - - public void setThumbnail(String thumbnail) { - this.thumbnail = thumbnail; - } -} diff --git a/spring-boot-ops/src/main/java/com/baeldung/graphql/AuthorDao.java b/spring-boot-ops/src/main/java/com/baeldung/graphql/AuthorDao.java deleted file mode 100644 index c799a558a7..0000000000 --- a/spring-boot-ops/src/main/java/com/baeldung/graphql/AuthorDao.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.graphql; - -import java.util.List; -import java.util.Optional; - -public class AuthorDao { - private List authors; - - public AuthorDao(List authors) { - this.authors = authors; - } - - public Optional getAuthor(String id) { - return authors.stream().filter(author -> id.equals(author.getId())).findFirst(); - } -} diff --git a/spring-boot-ops/src/main/java/com/baeldung/graphql/AuthorResolver.java b/spring-boot-ops/src/main/java/com/baeldung/graphql/AuthorResolver.java deleted file mode 100644 index 982c6cebc1..0000000000 --- a/spring-boot-ops/src/main/java/com/baeldung/graphql/AuthorResolver.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.graphql; - -import java.util.List; - -import com.coxautodev.graphql.tools.GraphQLResolver; - -public class AuthorResolver implements GraphQLResolver { - private PostDao postDao; - - public AuthorResolver(PostDao postDao) { - this.postDao = postDao; - } - - public List getPosts(Author author) { - return postDao.getAuthorPosts(author.getId()); - } -} diff --git a/spring-boot-ops/src/main/java/com/baeldung/graphql/GraphqlConfiguration.java b/spring-boot-ops/src/main/java/com/baeldung/graphql/GraphqlConfiguration.java deleted file mode 100644 index c5ae8bd772..0000000000 --- a/spring-boot-ops/src/main/java/com/baeldung/graphql/GraphqlConfiguration.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.baeldung.graphql; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class GraphqlConfiguration { - @Bean - public PostDao postDao() { - List posts = new ArrayList<>(); - for (int postId = 0; postId < 10; ++postId) { - for (int authorId = 0; authorId < 10; ++authorId) { - Post post = new Post(); - post.setId("Post" + authorId + postId); - post.setTitle("Post " + authorId + ":" + postId); - post.setText("Post " + postId + " + by author " + authorId); - post.setAuthorId("Author" + authorId); - posts.add(post); - } - } - return new PostDao(posts); - } - - @Bean - public AuthorDao authorDao() { - List authors = new ArrayList<>(); - for (int authorId = 0; authorId < 10; ++authorId) { - Author author = new Author(); - author.setId("Author" + authorId); - author.setName("Author " + authorId); - author.setThumbnail("http://example.com/authors/" + authorId); - authors.add(author); - } - return new AuthorDao(authors); - } - - @Bean - public PostResolver postResolver(AuthorDao authorDao) { - return new PostResolver(authorDao); - } - - @Bean - public AuthorResolver authorResolver(PostDao postDao) { - return new AuthorResolver(postDao); - } - - @Bean - public Query query(PostDao postDao) { - return new Query(postDao); - } - - @Bean - public Mutation mutation(PostDao postDao) { - return new Mutation(postDao); - } -} diff --git a/spring-boot-ops/src/main/java/com/baeldung/graphql/Mutation.java b/spring-boot-ops/src/main/java/com/baeldung/graphql/Mutation.java deleted file mode 100644 index 0e16e3c8b7..0000000000 --- a/spring-boot-ops/src/main/java/com/baeldung/graphql/Mutation.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.graphql; - -import java.util.UUID; - -import com.coxautodev.graphql.tools.GraphQLMutationResolver; - -public class Mutation implements GraphQLMutationResolver { - private PostDao postDao; - - public Mutation(PostDao postDao) { - this.postDao = postDao; - } - - public Post writePost(String title, String text, String category, String author) { - Post post = new Post(); - post.setId(UUID.randomUUID().toString()); - post.setTitle(title); - post.setText(text); - post.setCategory(category); - post.setAuthorId(author); - postDao.savePost(post); - - return post; - } -} diff --git a/spring-boot-ops/src/main/java/com/baeldung/graphql/Post.java b/spring-boot-ops/src/main/java/com/baeldung/graphql/Post.java deleted file mode 100644 index 14d3084841..0000000000 --- a/spring-boot-ops/src/main/java/com/baeldung/graphql/Post.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.baeldung.graphql; - -public class Post { - private String id; - private String title; - private String text; - private String category; - private String authorId; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public String getAuthorId() { - return authorId; - } - - public void setAuthorId(String authorId) { - this.authorId = authorId; - } -} diff --git a/spring-boot-ops/src/main/java/com/baeldung/graphql/PostDao.java b/spring-boot-ops/src/main/java/com/baeldung/graphql/PostDao.java deleted file mode 100644 index 0a755a7cf4..0000000000 --- a/spring-boot-ops/src/main/java/com/baeldung/graphql/PostDao.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.graphql; - -import java.util.List; -import java.util.stream.Collectors; - -public class PostDao { - private List posts; - - public PostDao(List posts) { - this.posts = posts; - } - - public List getRecentPosts(int count, int offset) { - return posts.stream().skip(offset).limit(count).collect(Collectors.toList()); - } - - public List getAuthorPosts(String author) { - return posts.stream().filter(post -> author.equals(post.getAuthorId())).collect(Collectors.toList()); - } - - public void savePost(Post post) { - posts.add(0, post); - } -} diff --git a/spring-boot-ops/src/main/java/com/baeldung/graphql/PostResolver.java b/spring-boot-ops/src/main/java/com/baeldung/graphql/PostResolver.java deleted file mode 100644 index dbfde330ea..0000000000 --- a/spring-boot-ops/src/main/java/com/baeldung/graphql/PostResolver.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.graphql; - -import java.util.Optional; - -import com.coxautodev.graphql.tools.GraphQLResolver; - -public class PostResolver implements GraphQLResolver { - private AuthorDao authorDao; - - public PostResolver(AuthorDao authorDao) { - this.authorDao = authorDao; - } - - public Optional getAuthor(Post post) { - return authorDao.getAuthor(post.getAuthorId()); - } -} diff --git a/spring-boot-ops/src/main/java/com/baeldung/graphql/Query.java b/spring-boot-ops/src/main/java/com/baeldung/graphql/Query.java deleted file mode 100644 index 7bb625798c..0000000000 --- a/spring-boot-ops/src/main/java/com/baeldung/graphql/Query.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.graphql; - -import java.util.List; - -import com.coxautodev.graphql.tools.GraphQLQueryResolver; - -public class Query implements GraphQLQueryResolver { - private PostDao postDao; - - public Query(PostDao postDao) { - this.postDao = postDao; - } - - public List recentPosts(int count, int offset) { - return postDao.getRecentPosts(count, offset); - } -} diff --git a/spring-boot-ops/src/main/java/org/baeldung/demo/DemoApplication.java b/spring-boot-ops/src/main/java/org/baeldung/demo/DemoApplication.java deleted file mode 100644 index 4a88fcea07..0000000000 --- a/spring-boot-ops/src/main/java/org/baeldung/demo/DemoApplication.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.baeldung.demo; - -import com.baeldung.graphql.GraphqlConfiguration; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import org.springframework.context.annotation.Import; - -@SpringBootApplication -@Import(GraphqlConfiguration.class) -public class DemoApplication { - - public static void main(String[] args) { - System.setProperty("spring.config.name", "demo"); - SpringApplication.run(DemoApplication.class, args); - } - -} diff --git a/spring-boot-ops/src/main/java/org/baeldung/demo/boottest/Employee.java b/spring-boot-ops/src/main/java/org/baeldung/demo/boottest/Employee.java deleted file mode 100644 index c1dd109f91..0000000000 --- a/spring-boot-ops/src/main/java/org/baeldung/demo/boottest/Employee.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.baeldung.demo.boottest; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.validation.constraints.Size; - -@Entity -@Table(name = "person") -public class Employee { - - public Employee() { - } - - public Employee(String name) { - this.name = name; - } - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - @Size(min = 3, max = 20) - private String name; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeRepository.java b/spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeRepository.java deleted file mode 100644 index 00fdbfaae4..0000000000 --- a/spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeRepository.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.demo.boottest; - -import java.util.List; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; -import org.springframework.transaction.annotation.Transactional; - -@Repository -@Transactional -public interface EmployeeRepository extends JpaRepository { - - public Employee findByName(String name); - - public List findAll(); - -} diff --git a/spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeRestController.java b/spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeRestController.java deleted file mode 100644 index 516bff0e8c..0000000000 --- a/spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeRestController.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.baeldung.demo.boottest; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/api") -public class EmployeeRestController { - - @Autowired - private EmployeeService employeeService; - - @PostMapping("/employees") - public ResponseEntity createEmployee(@RequestBody Employee employee) { - HttpStatus status = HttpStatus.CREATED; - Employee saved = employeeService.save(employee); - return new ResponseEntity<>(saved, status); - } - - @GetMapping("/employees") - public List getAllEmployees() { - return employeeService.getAllEmployees(); - } - -} diff --git a/spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeService.java b/spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeService.java deleted file mode 100644 index 07765a511c..0000000000 --- a/spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeService.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.baeldung.demo.boottest; - -import java.util.List; - -public interface EmployeeService { - - public Employee getEmployeeById(Long id); - - public Employee getEmployeeByName(String name); - - public List getAllEmployees(); - - public boolean exists(String email); - - public Employee save(Employee employee); -} diff --git a/spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeServiceImpl.java b/spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeServiceImpl.java deleted file mode 100644 index a1639b29cc..0000000000 --- a/spring-boot-ops/src/main/java/org/baeldung/demo/boottest/EmployeeServiceImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.baeldung.demo.boottest; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@Transactional -public class EmployeeServiceImpl implements EmployeeService { - - @Autowired - private EmployeeRepository employeeRepository; - - @Override - public Employee getEmployeeById(Long id) { - return employeeRepository.findById(id).orElse(null); - } - - @Override - public Employee getEmployeeByName(String name) { - return employeeRepository.findByName(name); - } - - @Override - public boolean exists(String name) { - if (employeeRepository.findByName(name) != null) { - return true; - } - return false; - } - - @Override - public Employee save(Employee employee) { - return employeeRepository.save(employee); - } - - @Override - public List getAllEmployees() { - return employeeRepository.findAll(); - } -} diff --git a/spring-boot-ops/src/main/java/org/baeldung/demo/components/FooService.java b/spring-boot-ops/src/main/java/org/baeldung/demo/components/FooService.java deleted file mode 100644 index 66943f6461..0000000000 --- a/spring-boot-ops/src/main/java/org/baeldung/demo/components/FooService.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.baeldung.demo.components; - -import org.baeldung.demo.model.Foo; -import org.baeldung.demo.repository.FooRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class FooService { - - @Autowired - private FooRepository fooRepository; - - public Foo getFooWithId(Integer id) throws Exception { - return fooRepository.findById(id).orElse(null); - } - - public Foo getFooWithName(String name) { - return fooRepository.findByName(name); - } -} \ No newline at end of file diff --git a/spring-boot-ops/src/main/java/org/baeldung/demo/exceptions/CommonException.java b/spring-boot-ops/src/main/java/org/baeldung/demo/exceptions/CommonException.java deleted file mode 100644 index 51dd7bbd44..0000000000 --- a/spring-boot-ops/src/main/java/org/baeldung/demo/exceptions/CommonException.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.baeldung.demo.exceptions; - -public class CommonException extends RuntimeException { - - /** - * - */ - private static final long serialVersionUID = 3080004140659213332L; - - public CommonException(String message) { - super(message); - } -} diff --git a/spring-boot-ops/src/main/java/org/baeldung/demo/exceptions/FooNotFoundException.java b/spring-boot-ops/src/main/java/org/baeldung/demo/exceptions/FooNotFoundException.java deleted file mode 100644 index 59796c58f0..0000000000 --- a/spring-boot-ops/src/main/java/org/baeldung/demo/exceptions/FooNotFoundException.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.baeldung.demo.exceptions; - -public class FooNotFoundException extends RuntimeException { - - /** - * - */ - private static final long serialVersionUID = 9042200028456133589L; - - public FooNotFoundException(String message) { - super(message); - } -} diff --git a/spring-boot-ops/src/main/java/org/baeldung/demo/model/Foo.java b/spring-boot-ops/src/main/java/org/baeldung/demo/model/Foo.java deleted file mode 100644 index e5638cfd3d..0000000000 --- a/spring-boot-ops/src/main/java/org/baeldung/demo/model/Foo.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.baeldung.demo.model; - -import java.io.Serializable; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; - -@Entity -public class Foo implements Serializable { - private static final long serialVersionUID = 1L; - @Id - @GeneratedValue - private Integer id; - private String name; - - public Foo() { - } - - public Foo(String name) { - this.name = name; - } - - public Foo(Integer id, String name) { - super(); - this.id = id; - this.name = name; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/spring-boot-ops/src/main/java/org/baeldung/demo/repository/FooRepository.java b/spring-boot-ops/src/main/java/org/baeldung/demo/repository/FooRepository.java deleted file mode 100644 index c04e0c7438..0000000000 --- a/spring-boot-ops/src/main/java/org/baeldung/demo/repository/FooRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.demo.repository; - -import org.baeldung.demo.model.Foo; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface FooRepository extends JpaRepository { - public Foo findByName(String name); -} diff --git a/spring-boot-ops/src/main/java/org/baeldung/demo/service/FooController.java b/spring-boot-ops/src/main/java/org/baeldung/demo/service/FooController.java deleted file mode 100644 index c28dcde1a7..0000000000 --- a/spring-boot-ops/src/main/java/org/baeldung/demo/service/FooController.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.baeldung.demo.service; - -import org.baeldung.demo.components.FooService; -import org.baeldung.demo.model.Foo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class FooController { - - @Autowired - private FooService fooService; - - @GetMapping("/{id}") - public Foo getFooWithId(@PathVariable Integer id) throws Exception { - return fooService.getFooWithId(id); - } - - @GetMapping("/") - public Foo getFooWithName(@RequestParam String name) throws Exception { - return fooService.getFooWithName(name); - } -} \ No newline at end of file diff --git a/spring-boot/README.MD b/spring-boot/README.MD index 3574c1be36..124dd17921 100644 --- a/spring-boot/README.MD +++ b/spring-boot/README.MD @@ -5,8 +5,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Quick Guide to @RestClientTest in Spring Boot](http://www.baeldung.com/restclienttest-in-spring-boot) - [A Guide to Spring in Eclipse STS](http://www.baeldung.com/eclipse-sts-spring) -- [Introduction to WebJars](http://www.baeldung.com/maven-webjars) -- [Create a Fat Jar App with Spring Boot](http://www.baeldung.com/deployable-fat-jar-spring-boot) - [The @ServletComponentScan Annotation in Spring Boot](http://www.baeldung.com/spring-servletcomponentscan) - [Intro to Building an Application with Spring Boot](http://www.baeldung.com/intro-to-spring-boot) - [How to Register a Servlet in a Java Web Application](http://www.baeldung.com/register-servlet) @@ -27,11 +25,9 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Guide to Spring Type Conversions](http://www.baeldung.com/spring-type-conversions) - [Quick Guide on data.sql and schema.sql Files in Spring Boot](http://www.baeldung.com/spring-boot-data-sql-and-schema-sql) - [Spring Data Java 8 Support](http://www.baeldung.com/spring-data-java-8) -- [A Quick Guide to Maven Wrapper](http://www.baeldung.com/maven-wrapper) - [An Introduction to Kong](http://www.baeldung.com/kong) - [Spring Boot Customize Whitelabel Error Page](http://www.baeldung.com/spring-boot-custom-error-page) - [Spring Boot: Configuring a Main Class](http://www.baeldung.com/spring-boot-main-class) -- [Shutdown a Spring Boot Application](http://www.baeldung.com/spring-boot-shutdown) - [A Quick Intro to the SpringBootServletInitializer](http://www.baeldung.com/spring-boot-servlet-initializer) - [How to Define a Spring Boot Filter?](http://www.baeldung.com/spring-boot-add-filter) - [How to Change the Default Port in Spring Boot](http://www.baeldung.com/spring-boot-change-port)