diff --git a/Step01.md b/Step01.md index 4ef426d..aaa3eae 100644 --- a/Step01.md +++ b/Step01.md @@ -1,8 +1,14 @@ ##What You Will Learn during this Step: - Set up an Maven Project with Eclipse. Intellij Link : https://www.jetbrains.com/help/idea/2016.2/getting-started-with-maven.html#create_maven_project - Include dependencies needed for Spring Boot. + - spring-boot-starter-web + - spring-boot-maven-plugin - Launch Your First Spring Boot Application. +##Cool thing to note! +Without a lot of configuration, we are up and running with a web application +- Refer https://github.com/in28minutes/SpringMvcStepByStep/blob/master/Step01.md and https://github.com/in28minutes/SpringMvcStepByStep/blob/master/Step11.md to understand the sort of stuff - web.xml, dispatcher servlet configuration, maven dependency management and plugins - that are need to launch a typical web application without Spring Boot! + ##What You Will NOT Learn during this Step: - Spring Boot does a lot of magic. This magic is called Auto Configuration. - We will discuss about different terms related to Spring Boot - Starter Parent, Starter projects, Auto configuration - in depth during our first 10 steps. diff --git a/Step02.md b/Step02.md index cb509a1..b7c51b1 100644 --- a/Step02.md +++ b/Step02.md @@ -1,46 +1,40 @@ ##What You Will Learn during this Step: -- Lets add dependencies and see if they are autowired in -- Lets make Spring Boot log the content from Spring Framework in Debug mode +- Lets add a RestController with a dependency and see Spring Boot Magic live + +##Quick Spring Primer +- What is dependency? +- @Component +- @Autowired ## Useful Snippets and References First Snippet ``` - @Component + @RestController class SomeBean { @Autowired private SomeDependency someDependency; - public String calculateSomething() { - // I'm a lazy bugger. Skipping calculation + @RequestMapping("/") + public String index() { return someDependency.getSomething(); } + } @Component class SomeDependency { public String getSomething() { - return "something"; + return "Hello! Welcome!"; } } -``` -Second Snippet -``` -System.out.println(ctx.getBean(SomeBean.class).calculateSomething()); -``` -Third Snippet -``` -/src/main/resources/application.properties -logging.level.org.springframework=DEBUG ``` -## Exercises - ## Files List ### /pom.xml ``` @@ -89,40 +83,38 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; @SpringBootApplication public class Application { public static void main(String[] args) { ApplicationContext ctx = SpringApplication.run(Application.class, args); - System.out.println(ctx.getBean(SomeBean.class).calculateSomething()); } - @Component + @RestController class SomeBean { @Autowired private SomeDependency someDependency; - public String calculateSomething() { - // I'm a lazy bugger. Skipping calculation + @RequestMapping("/") + public String index() { return someDependency.getSomething(); } + } @Component class SomeDependency { public String getSomething() { - return "something"; + return "Hello! Welcome!"; } } } -``` -### /src/main/resources/application.properties -``` -logging.level.org.springframework=DEBUG -``` +``` \ No newline at end of file diff --git a/Step03.md b/Step03.md new file mode 100644 index 0000000..a28ffd0 --- /dev/null +++ b/Step03.md @@ -0,0 +1,19 @@ +##What You Will Learn during this Step: +- First installment of how magic happens with Spring Boot. As a Spring Boot developer, you need to understand whats happening beneath the hood of Spring Boot! +- Understand Starter Parent +- How to override things defined in Starter Parent + +##Starter Parent +- Dependency Versions +- Java Versions +- Default Plugins + +## Useful Snippets and References +First Snippet +``` + + org.springframework.boot + spring-boot-starter-parent + 1.4.0.RELEASE + +``` \ No newline at end of file diff --git a/Step04.md b/Step04.md new file mode 100644 index 0000000..b5e455d --- /dev/null +++ b/Step04.md @@ -0,0 +1,18 @@ +##What You Will Learn during this Step: +- Understand Starter Parent +- How to override things defined in Starter Parent + +##Starter Parent +- Dependency Versions +- Java Versions +- Default Plugins + +## Useful Snippets and References +First Snippet +``` + + org.springframework.boot + spring-boot-starter-parent + 1.4.0.RELEASE + +``` \ No newline at end of file diff --git a/src/main/java/com/in28minutes/springboot/Application.java b/src/main/java/com/in28minutes/springboot/Application.java index 070e07b..f48711a 100644 --- a/src/main/java/com/in28minutes/springboot/Application.java +++ b/src/main/java/com/in28minutes/springboot/Application.java @@ -5,33 +5,35 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; @SpringBootApplication public class Application { public static void main(String[] args) { ApplicationContext ctx = SpringApplication.run(Application.class, args); - System.out.println(ctx.getBean(SomeBean.class).calculateSomething()); } - @Component + @RestController class SomeBean { @Autowired private SomeDependency someDependency; - public String calculateSomething() { - // I'm a lazy bugger. Skipping calculation + @RequestMapping("/") + public String index() { return someDependency.getSomething(); } + } @Component class SomeDependency { public String getSomething() { - return "something"; + return "Hello! Welcome!"; } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index b2f5312..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -logging.level.org.springframework=DEBUG \ No newline at end of file