From 1f4dfef8db56afd2ba9324fc30d6b62159a96dcf Mon Sep 17 00:00:00 2001 From: vatsalgosar Date: Sat, 13 Jul 2019 05:49:41 +0530 Subject: [PATCH 1/7] BAEL-2728 | vatsalgosar@gmail.com - Sprint Boot application implementation using @SpringBootConfiguration annotation --- spring-boot-configuration/.gitignore | 31 ++++++++ spring-boot-configuration/README.md | 10 +++ spring-boot-configuration/pom.xml | 72 +++++++++++++++++++ .../main/java/com/baeldung/Application.java | 20 ++++++ .../main/java/com/baeldung/SwaggerConfig.java | 22 ++++++ .../baeldung/controller/PersonController.java | 39 ++++++++++ .../main/java/com/baeldung/domain/Person.java | 38 ++++++++++ .../exception/PersonNotFoundException.java | 8 +++ .../baeldung/repository/PersonRepository.java | 9 +++ .../com/baeldung/service/PersonService.java | 34 +++++++++ .../src/main/resources/application.properties | 3 + .../src/main/resources/schema.sql | 5 ++ .../java/com/baeldung/ApplicationTests.java | 16 +++++ 13 files changed, 307 insertions(+) create mode 100644 spring-boot-configuration/.gitignore create mode 100644 spring-boot-configuration/README.md create mode 100644 spring-boot-configuration/pom.xml create mode 100644 spring-boot-configuration/src/main/java/com/baeldung/Application.java create mode 100644 spring-boot-configuration/src/main/java/com/baeldung/SwaggerConfig.java create mode 100644 spring-boot-configuration/src/main/java/com/baeldung/controller/PersonController.java create mode 100644 spring-boot-configuration/src/main/java/com/baeldung/domain/Person.java create mode 100644 spring-boot-configuration/src/main/java/com/baeldung/exception/PersonNotFoundException.java create mode 100644 spring-boot-configuration/src/main/java/com/baeldung/repository/PersonRepository.java create mode 100644 spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java create mode 100644 spring-boot-configuration/src/main/resources/application.properties create mode 100644 spring-boot-configuration/src/main/resources/schema.sql create mode 100644 spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java diff --git a/spring-boot-configuration/.gitignore b/spring-boot-configuration/.gitignore new file mode 100644 index 0000000000..a2a3040aa8 --- /dev/null +++ b/spring-boot-configuration/.gitignore @@ -0,0 +1,31 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/** +!**/src/test/** + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ + +### VS Code ### +.vscode/ diff --git a/spring-boot-configuration/README.md b/spring-boot-configuration/README.md new file mode 100644 index 0000000000..35472d575a --- /dev/null +++ b/spring-boot-configuration/README.md @@ -0,0 +1,10 @@ +Article: +SprintBootConfiguration annotation + +commands: +mvn clean install +mvn spring-boot:run + +Swagger endpoints: +http://localhost:8080/v2/api-docs +http://localhost:8080/swagger-ui.html \ No newline at end of file diff --git a/spring-boot-configuration/pom.xml b/spring-boot-configuration/pom.xml new file mode 100644 index 0000000000..ede2504272 --- /dev/null +++ b/spring-boot-configuration/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.6.RELEASE + + + com.baeldung + spring-boot-configuration + 0.0.1-SNAPSHOT + spring-boot-configuration + Demo project for Spring Boot Configuration + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + + + com.h2database + h2 + runtime + + + + + org.hibernate + hibernate-entitymanager + + + + + io.springfox + springfox-swagger2 + 2.9.2 + + + io.springfox + springfox-swagger-ui + 2.9.2 + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/spring-boot-configuration/src/main/java/com/baeldung/Application.java b/spring-boot-configuration/src/main/java/com/baeldung/Application.java new file mode 100644 index 0000000000..019cc5b57c --- /dev/null +++ b/spring-boot-configuration/src/main/java/com/baeldung/Application.java @@ -0,0 +1,20 @@ +package com.baeldung; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; + +@EnableAutoConfiguration +@ComponentScan(basePackages = {"com.baeldung.*"}) +@SpringBootConfiguration +@Import({SwaggerConfig.class}) +public class Application { + + public static void main(String[] args) { + + SpringApplication.run(Application.class, args); + } +} + diff --git a/spring-boot-configuration/src/main/java/com/baeldung/SwaggerConfig.java b/spring-boot-configuration/src/main/java/com/baeldung/SwaggerConfig.java new file mode 100644 index 0000000000..c69e65bc4e --- /dev/null +++ b/spring-boot-configuration/src/main/java/com/baeldung/SwaggerConfig.java @@ -0,0 +1,22 @@ +package com.baeldung; + +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.context.annotation.Bean; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@SpringBootConfiguration +@EnableSwagger2 +public class SwaggerConfig { + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build(); + } +} diff --git a/spring-boot-configuration/src/main/java/com/baeldung/controller/PersonController.java b/spring-boot-configuration/src/main/java/com/baeldung/controller/PersonController.java new file mode 100644 index 0000000000..10d7386132 --- /dev/null +++ b/spring-boot-configuration/src/main/java/com/baeldung/controller/PersonController.java @@ -0,0 +1,39 @@ +package com.baeldung.controller; + +import com.baeldung.domain.Person; +import com.baeldung.exception.PersonNotFoundException; +import com.baeldung.service.PersonService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/persons") +public class PersonController { + + @Autowired + PersonService personService; + + @GetMapping + public List getPersons() { + return personService.getPersons(); + } + + @PostMapping + public void addPerson(@RequestBody Person person) { + personService.add(person); + } + + @GetMapping("/{id}") + public Person getPersonById(@PathVariable(required = true) long id) throws PersonNotFoundException { + return personService.getPersonById(id); + } + + @DeleteMapping("/{id}") + public void removePerson(@PathVariable(required = true) long id) { + personService.delete(id); + } + + +} diff --git a/spring-boot-configuration/src/main/java/com/baeldung/domain/Person.java b/spring-boot-configuration/src/main/java/com/baeldung/domain/Person.java new file mode 100644 index 0000000000..e63836420c --- /dev/null +++ b/spring-boot-configuration/src/main/java/com/baeldung/domain/Person.java @@ -0,0 +1,38 @@ +package com.baeldung.domain; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +public class Person { + + @Id + @GeneratedValue + private long id; + private String name; + + public Person() {} + + public Person(long id, String name) { + this.id = id; + this.name = 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; + } +} + diff --git a/spring-boot-configuration/src/main/java/com/baeldung/exception/PersonNotFoundException.java b/spring-boot-configuration/src/main/java/com/baeldung/exception/PersonNotFoundException.java new file mode 100644 index 0000000000..048197a072 --- /dev/null +++ b/spring-boot-configuration/src/main/java/com/baeldung/exception/PersonNotFoundException.java @@ -0,0 +1,8 @@ +package com.baeldung.exception; + +public class PersonNotFoundException extends Exception { + + public PersonNotFoundException(String message) { + super(message); + } +} diff --git a/spring-boot-configuration/src/main/java/com/baeldung/repository/PersonRepository.java b/spring-boot-configuration/src/main/java/com/baeldung/repository/PersonRepository.java new file mode 100644 index 0000000000..b542b5ea0b --- /dev/null +++ b/spring-boot-configuration/src/main/java/com/baeldung/repository/PersonRepository.java @@ -0,0 +1,9 @@ +package com.baeldung.repository; + +import com.baeldung.domain.Person; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface PersonRepository extends CrudRepository { +} diff --git a/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java b/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java new file mode 100644 index 0000000000..e5929177de --- /dev/null +++ b/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java @@ -0,0 +1,34 @@ +package com.baeldung.service; + +import com.baeldung.domain.Person; +import com.baeldung.exception.PersonNotFoundException; +import com.baeldung.repository.PersonRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Optional; + +@Service +public class PersonService { + + @Autowired + PersonRepository personRepository; + + public void add(Person person) { + personRepository.save(person); + } + + public void delete(long id) { + personRepository.deleteById(id); + } + + public List getPersons() { + return (List) personRepository.findAll(); + } + + public Person getPersonById(long id) throws PersonNotFoundException { + Optional optionalDog = personRepository.findById(id); + return optionalDog.orElseThrow(() -> new PersonNotFoundException("Couldn't find a Person with id: " + id)); + } +} diff --git a/spring-boot-configuration/src/main/resources/application.properties b/spring-boot-configuration/src/main/resources/application.properties new file mode 100644 index 0000000000..7de28fe306 --- /dev/null +++ b/spring-boot-configuration/src/main/resources/application.properties @@ -0,0 +1,3 @@ +# H2 +spring.h2.console.enabled=true +spring.h2.console.path=/h2 diff --git a/spring-boot-configuration/src/main/resources/schema.sql b/spring-boot-configuration/src/main/resources/schema.sql new file mode 100644 index 0000000000..02a7aca232 --- /dev/null +++ b/spring-boot-configuration/src/main/resources/schema.sql @@ -0,0 +1,5 @@ +CREATE TABLE `person` ( + `id` INT(11) NOT NULL, + `name` VARCHAR(50) NULL DEFAULT NULL, + PRIMARY KEY (`id`) +); \ No newline at end of file diff --git a/spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java b/spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java new file mode 100644 index 0000000000..f239fc76cc --- /dev/null +++ b/spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java @@ -0,0 +1,16 @@ +package com.baeldung; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class ApplicationTests { + + @Test + public void contextLoads() { + } + +} From f43db12fcbdac8b0c47cede959066f7de53ea46d Mon Sep 17 00:00:00 2001 From: vatsalgosar Date: Tue, 16 Jul 2019 01:55:08 +0530 Subject: [PATCH 2/7] BAEL-2728 | vatsalgosar@gmail.com - Adding spring-boot-configuration project to spring-boot-bootstrap module --- .../spring-boot-configuration}/README.md | 0 .../spring-boot-configuration}/pom.xml | 14 +-------- .../main/java/com/baeldung/Application.java | 9 ++++-- .../baeldung/controller/PersonController.java | 0 .../main/java/com/baeldung/domain/Person.java | 0 .../exception/PersonNotFoundException.java | 0 .../baeldung/repository/PersonRepository.java | 0 .../com/baeldung/service/PersonService.java | 2 +- .../src/main/resources/application.properties | 0 .../src/main/resources/schema.sql | 0 .../java/com/baeldung/ApplicationTests.java | 0 spring-boot-configuration/.gitignore | 31 ------------------- .../main/java/com/baeldung/SwaggerConfig.java | 22 ------------- 13 files changed, 9 insertions(+), 69 deletions(-) rename {spring-boot-configuration => spring-boot-bootstrap/spring-boot-configuration}/README.md (100%) rename {spring-boot-configuration => spring-boot-bootstrap/spring-boot-configuration}/pom.xml (84%) rename {spring-boot-configuration => spring-boot-bootstrap/spring-boot-configuration}/src/main/java/com/baeldung/Application.java (75%) rename {spring-boot-configuration => spring-boot-bootstrap/spring-boot-configuration}/src/main/java/com/baeldung/controller/PersonController.java (100%) rename {spring-boot-configuration => spring-boot-bootstrap/spring-boot-configuration}/src/main/java/com/baeldung/domain/Person.java (100%) rename {spring-boot-configuration => spring-boot-bootstrap/spring-boot-configuration}/src/main/java/com/baeldung/exception/PersonNotFoundException.java (100%) rename {spring-boot-configuration => spring-boot-bootstrap/spring-boot-configuration}/src/main/java/com/baeldung/repository/PersonRepository.java (100%) rename {spring-boot-configuration => spring-boot-bootstrap/spring-boot-configuration}/src/main/java/com/baeldung/service/PersonService.java (98%) rename {spring-boot-configuration => spring-boot-bootstrap/spring-boot-configuration}/src/main/resources/application.properties (100%) rename {spring-boot-configuration => spring-boot-bootstrap/spring-boot-configuration}/src/main/resources/schema.sql (100%) rename {spring-boot-configuration => spring-boot-bootstrap/spring-boot-configuration}/src/test/java/com/baeldung/ApplicationTests.java (100%) delete mode 100644 spring-boot-configuration/.gitignore delete mode 100644 spring-boot-configuration/src/main/java/com/baeldung/SwaggerConfig.java diff --git a/spring-boot-configuration/README.md b/spring-boot-bootstrap/spring-boot-configuration/README.md similarity index 100% rename from spring-boot-configuration/README.md rename to spring-boot-bootstrap/spring-boot-configuration/README.md diff --git a/spring-boot-configuration/pom.xml b/spring-boot-bootstrap/spring-boot-configuration/pom.xml similarity index 84% rename from spring-boot-configuration/pom.xml rename to spring-boot-bootstrap/spring-boot-configuration/pom.xml index ede2504272..02b2e53159 100644 --- a/spring-boot-configuration/pom.xml +++ b/spring-boot-bootstrap/spring-boot-configuration/pom.xml @@ -40,19 +40,7 @@ org.hibernate hibernate-entitymanager - - - - io.springfox - springfox-swagger2 - 2.9.2 - - - io.springfox - springfox-swagger-ui - 2.9.2 - - + org.springframework.boot spring-boot-starter-test diff --git a/spring-boot-configuration/src/main/java/com/baeldung/Application.java b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/Application.java similarity index 75% rename from spring-boot-configuration/src/main/java/com/baeldung/Application.java rename to spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/Application.java index 019cc5b57c..7021ae62fa 100644 --- a/spring-boot-configuration/src/main/java/com/baeldung/Application.java +++ b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/Application.java @@ -1,20 +1,25 @@ package com.baeldung; +import com.baeldung.service.PersonService; import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Import; @EnableAutoConfiguration @ComponentScan(basePackages = {"com.baeldung.*"}) @SpringBootConfiguration -@Import({SwaggerConfig.class}) public class Application { public static void main(String[] args) { - SpringApplication.run(Application.class, args); } + + @Bean + public PersonService personService() { + return new PersonService(); + } } diff --git a/spring-boot-configuration/src/main/java/com/baeldung/controller/PersonController.java b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/controller/PersonController.java similarity index 100% rename from spring-boot-configuration/src/main/java/com/baeldung/controller/PersonController.java rename to spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/controller/PersonController.java diff --git a/spring-boot-configuration/src/main/java/com/baeldung/domain/Person.java b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/domain/Person.java similarity index 100% rename from spring-boot-configuration/src/main/java/com/baeldung/domain/Person.java rename to spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/domain/Person.java diff --git a/spring-boot-configuration/src/main/java/com/baeldung/exception/PersonNotFoundException.java b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/exception/PersonNotFoundException.java similarity index 100% rename from spring-boot-configuration/src/main/java/com/baeldung/exception/PersonNotFoundException.java rename to spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/exception/PersonNotFoundException.java diff --git a/spring-boot-configuration/src/main/java/com/baeldung/repository/PersonRepository.java b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/repository/PersonRepository.java similarity index 100% rename from spring-boot-configuration/src/main/java/com/baeldung/repository/PersonRepository.java rename to spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/repository/PersonRepository.java diff --git a/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java similarity index 98% rename from spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java rename to spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java index e5929177de..74f7cb0a70 100644 --- a/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java +++ b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java @@ -9,7 +9,7 @@ import org.springframework.stereotype.Service; import java.util.List; import java.util.Optional; -@Service +//@Service public class PersonService { @Autowired diff --git a/spring-boot-configuration/src/main/resources/application.properties b/spring-boot-bootstrap/spring-boot-configuration/src/main/resources/application.properties similarity index 100% rename from spring-boot-configuration/src/main/resources/application.properties rename to spring-boot-bootstrap/spring-boot-configuration/src/main/resources/application.properties diff --git a/spring-boot-configuration/src/main/resources/schema.sql b/spring-boot-bootstrap/spring-boot-configuration/src/main/resources/schema.sql similarity index 100% rename from spring-boot-configuration/src/main/resources/schema.sql rename to spring-boot-bootstrap/spring-boot-configuration/src/main/resources/schema.sql diff --git a/spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java b/spring-boot-bootstrap/spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java similarity index 100% rename from spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java rename to spring-boot-bootstrap/spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java diff --git a/spring-boot-configuration/.gitignore b/spring-boot-configuration/.gitignore deleted file mode 100644 index a2a3040aa8..0000000000 --- a/spring-boot-configuration/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -HELP.md -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/** -!**/src/test/** - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ - -### VS Code ### -.vscode/ diff --git a/spring-boot-configuration/src/main/java/com/baeldung/SwaggerConfig.java b/spring-boot-configuration/src/main/java/com/baeldung/SwaggerConfig.java deleted file mode 100644 index c69e65bc4e..0000000000 --- a/spring-boot-configuration/src/main/java/com/baeldung/SwaggerConfig.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung; - -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.context.annotation.Bean; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@SpringBootConfiguration -@EnableSwagger2 -public class SwaggerConfig { - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.any()) - .build(); - } -} From eaa0c63620d0ac7807a6ea65d95defcd8202d879 Mon Sep 17 00:00:00 2001 From: vatsalgosar Date: Wed, 24 Jul 2019 00:18:45 +0530 Subject: [PATCH 3/7] BAEL-2728 - Removed unnecessary code --- .../spring-boot-configuration/README.md | 4 - .../spring-boot-configuration/pom.xml | 88 ++++++++----------- .../main/java/com/baeldung/Application.java | 24 +++-- .../ServiceImpl/PersonServiceImpl.java | 6 ++ .../baeldung/controller/PersonController.java | 39 -------- .../main/java/com/baeldung/domain/Person.java | 38 -------- .../exception/PersonNotFoundException.java | 8 -- .../baeldung/repository/PersonRepository.java | 9 -- .../com/baeldung/service/PersonService.java | 32 +------ .../src/main/resources/application.properties | 3 - .../src/main/resources/schema.sql | 5 -- .../java/com/baeldung/ApplicationTests.java | 6 +- 12 files changed, 56 insertions(+), 206 deletions(-) create mode 100644 spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/ServiceImpl/PersonServiceImpl.java delete mode 100644 spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/controller/PersonController.java delete mode 100644 spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/domain/Person.java delete mode 100644 spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/exception/PersonNotFoundException.java delete mode 100644 spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/repository/PersonRepository.java delete mode 100644 spring-boot-bootstrap/spring-boot-configuration/src/main/resources/application.properties delete mode 100644 spring-boot-bootstrap/spring-boot-configuration/src/main/resources/schema.sql diff --git a/spring-boot-bootstrap/spring-boot-configuration/README.md b/spring-boot-bootstrap/spring-boot-configuration/README.md index 35472d575a..d5ec5f63da 100644 --- a/spring-boot-bootstrap/spring-boot-configuration/README.md +++ b/spring-boot-bootstrap/spring-boot-configuration/README.md @@ -4,7 +4,3 @@ SprintBootConfiguration annotation commands: mvn clean install mvn spring-boot:run - -Swagger endpoints: -http://localhost:8080/v2/api-docs -http://localhost:8080/swagger-ui.html \ No newline at end of file diff --git a/spring-boot-bootstrap/spring-boot-configuration/pom.xml b/spring-boot-bootstrap/spring-boot-configuration/pom.xml index 02b2e53159..d7b4122c20 100644 --- a/spring-boot-bootstrap/spring-boot-configuration/pom.xml +++ b/spring-boot-bootstrap/spring-boot-configuration/pom.xml @@ -1,60 +1,42 @@ - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.1.6.RELEASE - - - com.baeldung - spring-boot-configuration - 0.0.1-SNAPSHOT - spring-boot-configuration - Demo project for Spring Boot Configuration + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.6.RELEASE + + + com.baeldung + spring-boot-configuration + 0.0.1-SNAPSHOT + spring-boot-configuration + Demo project for Spring Boot Configuration - - 1.8 - + + 1.8 + - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-web - + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-test + test + + - - - com.h2database - h2 - runtime - - - - - org.hibernate - hibernate-entitymanager - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - + + + + org.springframework.boot + spring-boot-maven-plugin + + + diff --git a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/Application.java b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/Application.java index 7021ae62fa..15adb4bb3e 100644 --- a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/Application.java +++ b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/Application.java @@ -1,25 +1,23 @@ package com.baeldung; -import com.baeldung.service.PersonService; import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Import; -@EnableAutoConfiguration -@ComponentScan(basePackages = {"com.baeldung.*"}) +import com.baeldung.ServiceImpl.PersonServiceImpl; +import com.baeldung.service.PersonService; + +@ComponentScan(basePackages = { "com.baeldung.*" }) @SpringBootConfiguration public class Application { - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } - @Bean - public PersonService personService() { - return new PersonService(); - } + @Bean + public PersonService personService() { + return new PersonServiceImpl(); + } } - diff --git a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/ServiceImpl/PersonServiceImpl.java b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/ServiceImpl/PersonServiceImpl.java new file mode 100644 index 0000000000..f08fbaa7f2 --- /dev/null +++ b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/ServiceImpl/PersonServiceImpl.java @@ -0,0 +1,6 @@ +package com.baeldung.ServiceImpl; + +import com.baeldung.service.PersonService; + +public class PersonServiceImpl implements PersonService { +} diff --git a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/controller/PersonController.java b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/controller/PersonController.java deleted file mode 100644 index 10d7386132..0000000000 --- a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/controller/PersonController.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.baeldung.controller; - -import com.baeldung.domain.Person; -import com.baeldung.exception.PersonNotFoundException; -import com.baeldung.service.PersonService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -@RestController -@RequestMapping("/persons") -public class PersonController { - - @Autowired - PersonService personService; - - @GetMapping - public List getPersons() { - return personService.getPersons(); - } - - @PostMapping - public void addPerson(@RequestBody Person person) { - personService.add(person); - } - - @GetMapping("/{id}") - public Person getPersonById(@PathVariable(required = true) long id) throws PersonNotFoundException { - return personService.getPersonById(id); - } - - @DeleteMapping("/{id}") - public void removePerson(@PathVariable(required = true) long id) { - personService.delete(id); - } - - -} diff --git a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/domain/Person.java b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/domain/Person.java deleted file mode 100644 index e63836420c..0000000000 --- a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/domain/Person.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.baeldung.domain; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; - -@Entity -public class Person { - - @Id - @GeneratedValue - private long id; - private String name; - - public Person() {} - - public Person(long id, String name) { - this.id = id; - this.name = 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; - } -} - diff --git a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/exception/PersonNotFoundException.java b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/exception/PersonNotFoundException.java deleted file mode 100644 index 048197a072..0000000000 --- a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/exception/PersonNotFoundException.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.exception; - -public class PersonNotFoundException extends Exception { - - public PersonNotFoundException(String message) { - super(message); - } -} diff --git a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/repository/PersonRepository.java b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/repository/PersonRepository.java deleted file mode 100644 index b542b5ea0b..0000000000 --- a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/repository/PersonRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.repository; - -import com.baeldung.domain.Person; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface PersonRepository extends CrudRepository { -} diff --git a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java index 74f7cb0a70..e959e3b835 100644 --- a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java +++ b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java @@ -1,34 +1,4 @@ package com.baeldung.service; -import com.baeldung.domain.Person; -import com.baeldung.exception.PersonNotFoundException; -import com.baeldung.repository.PersonRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.Optional; - -//@Service -public class PersonService { - - @Autowired - PersonRepository personRepository; - - public void add(Person person) { - personRepository.save(person); - } - - public void delete(long id) { - personRepository.deleteById(id); - } - - public List getPersons() { - return (List) personRepository.findAll(); - } - - public Person getPersonById(long id) throws PersonNotFoundException { - Optional optionalDog = personRepository.findById(id); - return optionalDog.orElseThrow(() -> new PersonNotFoundException("Couldn't find a Person with id: " + id)); - } +public interface PersonService { } diff --git a/spring-boot-bootstrap/spring-boot-configuration/src/main/resources/application.properties b/spring-boot-bootstrap/spring-boot-configuration/src/main/resources/application.properties deleted file mode 100644 index 7de28fe306..0000000000 --- a/spring-boot-bootstrap/spring-boot-configuration/src/main/resources/application.properties +++ /dev/null @@ -1,3 +0,0 @@ -# H2 -spring.h2.console.enabled=true -spring.h2.console.path=/h2 diff --git a/spring-boot-bootstrap/spring-boot-configuration/src/main/resources/schema.sql b/spring-boot-bootstrap/spring-boot-configuration/src/main/resources/schema.sql deleted file mode 100644 index 02a7aca232..0000000000 --- a/spring-boot-bootstrap/spring-boot-configuration/src/main/resources/schema.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE `person` ( - `id` INT(11) NOT NULL, - `name` VARCHAR(50) NULL DEFAULT NULL, - PRIMARY KEY (`id`) -); \ No newline at end of file diff --git a/spring-boot-bootstrap/spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java b/spring-boot-bootstrap/spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java index f239fc76cc..3bd3cc2ec6 100644 --- a/spring-boot-bootstrap/spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java +++ b/spring-boot-bootstrap/spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java @@ -9,8 +9,8 @@ import org.springframework.test.context.junit4.SpringRunner; @SpringBootTest public class ApplicationTests { - @Test - public void contextLoads() { - } + @Test + public void contextLoads() { + } } From ba8d468603c6544d3269b495080e2858d6ae1695 Mon Sep 17 00:00:00 2001 From: vatsalgosar Date: Fri, 26 Jul 2019 02:01:33 +0530 Subject: [PATCH 4/7] module changed --- .../spring-boot-configuration/README.md | 6 --- .../spring-boot-configuration/pom.xml | 42 ------------------- .../ServiceImpl/PersonServiceImpl.java | 6 --- .../com/baeldung/service/PersonService.java | 4 -- .../java/com/baeldung/ApplicationTests.java | 16 ------- .../springbootconfiguration}/Application.java | 6 +-- .../ServiceImpl/PersonServiceImpl.java | 6 +++ .../service/PersonService.java | 4 ++ 8 files changed, 13 insertions(+), 77 deletions(-) delete mode 100644 spring-boot-bootstrap/spring-boot-configuration/README.md delete mode 100644 spring-boot-bootstrap/spring-boot-configuration/pom.xml delete mode 100644 spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/ServiceImpl/PersonServiceImpl.java delete mode 100644 spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java delete mode 100644 spring-boot-bootstrap/spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java rename spring-boot-bootstrap/{spring-boot-configuration/src/main/java/com/baeldung => src/main/java/com/baeldung/springbootconfiguration}/Application.java (74%) create mode 100644 spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/ServiceImpl/PersonServiceImpl.java create mode 100644 spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/service/PersonService.java diff --git a/spring-boot-bootstrap/spring-boot-configuration/README.md b/spring-boot-bootstrap/spring-boot-configuration/README.md deleted file mode 100644 index d5ec5f63da..0000000000 --- a/spring-boot-bootstrap/spring-boot-configuration/README.md +++ /dev/null @@ -1,6 +0,0 @@ -Article: -SprintBootConfiguration annotation - -commands: -mvn clean install -mvn spring-boot:run diff --git a/spring-boot-bootstrap/spring-boot-configuration/pom.xml b/spring-boot-bootstrap/spring-boot-configuration/pom.xml deleted file mode 100644 index d7b4122c20..0000000000 --- a/spring-boot-bootstrap/spring-boot-configuration/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.1.6.RELEASE - - - com.baeldung - spring-boot-configuration - 0.0.1-SNAPSHOT - spring-boot-configuration - Demo project for Spring Boot Configuration - - - 1.8 - - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/ServiceImpl/PersonServiceImpl.java b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/ServiceImpl/PersonServiceImpl.java deleted file mode 100644 index f08fbaa7f2..0000000000 --- a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/ServiceImpl/PersonServiceImpl.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.baeldung.ServiceImpl; - -import com.baeldung.service.PersonService; - -public class PersonServiceImpl implements PersonService { -} diff --git a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java b/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java deleted file mode 100644 index e959e3b835..0000000000 --- a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/service/PersonService.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.baeldung.service; - -public interface PersonService { -} diff --git a/spring-boot-bootstrap/spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java b/spring-boot-bootstrap/spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java deleted file mode 100644 index 3bd3cc2ec6..0000000000 --- a/spring-boot-bootstrap/spring-boot-configuration/src/test/java/com/baeldung/ApplicationTests.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class ApplicationTests { - - @Test - public void contextLoads() { - } - -} diff --git a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/Application.java b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java similarity index 74% rename from spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/Application.java rename to spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java index 15adb4bb3e..ef9df2bf4a 100644 --- a/spring-boot-bootstrap/spring-boot-configuration/src/main/java/com/baeldung/Application.java +++ b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java @@ -1,12 +1,12 @@ -package com.baeldung; +package com.baeldung.springbootconfiguration; import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringBootConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; -import com.baeldung.ServiceImpl.PersonServiceImpl; -import com.baeldung.service.PersonService; +import com.baeldung.springbootconfiguration.ServiceImpl.PersonServiceImpl; +import com.baeldung.springbootconfiguration.service.PersonService; @ComponentScan(basePackages = { "com.baeldung.*" }) @SpringBootConfiguration diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/ServiceImpl/PersonServiceImpl.java b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/ServiceImpl/PersonServiceImpl.java new file mode 100644 index 0000000000..3bec4e4b12 --- /dev/null +++ b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/ServiceImpl/PersonServiceImpl.java @@ -0,0 +1,6 @@ +package com.baeldung.springbootconfiguration.ServiceImpl; + +import com.baeldung.springbootconfiguration.service.PersonService; + +public class PersonServiceImpl implements PersonService { +} diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/service/PersonService.java b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/service/PersonService.java new file mode 100644 index 0000000000..5a18edde33 --- /dev/null +++ b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/service/PersonService.java @@ -0,0 +1,4 @@ +package com.baeldung.springbootconfiguration.service; + +public interface PersonService { +} From 85f4a100db5e80263911470eac65bb365dfa31be Mon Sep 17 00:00:00 2001 From: vatsalgosar Date: Fri, 26 Jul 2019 10:05:46 +0530 Subject: [PATCH 5/7] updated packages --- .../com/baeldung/springbootconfiguration/Application.java | 3 --- .../com/baeldung/springbootconfiguration/PersonService.java | 4 ++++ .../baeldung/springbootconfiguration/PersonServiceImpl.java | 4 ++++ .../ServiceImpl/PersonServiceImpl.java | 6 ------ .../springbootconfiguration/service/PersonService.java | 4 ---- 5 files changed, 8 insertions(+), 13 deletions(-) create mode 100644 spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonService.java create mode 100644 spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonServiceImpl.java delete mode 100644 spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/ServiceImpl/PersonServiceImpl.java delete mode 100644 spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/service/PersonService.java diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java index ef9df2bf4a..146d59a81b 100644 --- a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java +++ b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java @@ -5,9 +5,6 @@ import org.springframework.boot.SpringBootConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; -import com.baeldung.springbootconfiguration.ServiceImpl.PersonServiceImpl; -import com.baeldung.springbootconfiguration.service.PersonService; - @ComponentScan(basePackages = { "com.baeldung.*" }) @SpringBootConfiguration public class Application { diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonService.java b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonService.java new file mode 100644 index 0000000000..4909d957e5 --- /dev/null +++ b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonService.java @@ -0,0 +1,4 @@ +package com.baeldung.springbootconfiguration; + +public interface PersonService { +} diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonServiceImpl.java b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonServiceImpl.java new file mode 100644 index 0000000000..9f2af33e8e --- /dev/null +++ b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonServiceImpl.java @@ -0,0 +1,4 @@ +package com.baeldung.springbootconfiguration; + +public class PersonServiceImpl implements PersonService { +} diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/ServiceImpl/PersonServiceImpl.java b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/ServiceImpl/PersonServiceImpl.java deleted file mode 100644 index 3bec4e4b12..0000000000 --- a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/ServiceImpl/PersonServiceImpl.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.baeldung.springbootconfiguration.ServiceImpl; - -import com.baeldung.springbootconfiguration.service.PersonService; - -public class PersonServiceImpl implements PersonService { -} diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/service/PersonService.java b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/service/PersonService.java deleted file mode 100644 index 5a18edde33..0000000000 --- a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/service/PersonService.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.baeldung.springbootconfiguration.service; - -public interface PersonService { -} From aa0658c823736fdc2d8c171f2f852a328674a76f Mon Sep 17 00:00:00 2001 From: vatsalgosar Date: Fri, 26 Jul 2019 10:09:08 +0530 Subject: [PATCH 6/7] changed package scan --- .../java/com/baeldung/springbootconfiguration/Application.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java index 146d59a81b..ae81b4872f 100644 --- a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java +++ b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java @@ -5,7 +5,7 @@ import org.springframework.boot.SpringBootConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; -@ComponentScan(basePackages = { "com.baeldung.*" }) +@ComponentScan(basePackages = {"com.baeldung.springbootconfiguration"}) @SpringBootConfiguration public class Application { From 78881a0a016ed94d139f85d9dab158bf19bf8ec4 Mon Sep 17 00:00:00 2001 From: vatsalgosar Date: Fri, 26 Jul 2019 10:10:46 +0530 Subject: [PATCH 7/7] package scan --- .../java/com/baeldung/springbootconfiguration/Application.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java index ae81b4872f..d4c8010d2b 100644 --- a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java +++ b/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java @@ -5,7 +5,7 @@ import org.springframework.boot.SpringBootConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; -@ComponentScan(basePackages = {"com.baeldung.springbootconfiguration"}) +@ComponentScan(basePackages = {"com.baeldung.springbootconfiguration.*"}) @SpringBootConfiguration public class Application {