├── .gitignore
├── 01.Spring-Boot-Introduction-In-10-Steps
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── code-21July2017.zip
├── mvnw
├── mvnw.cmd
├── notes.txt
├── pom.xml
├── readme.md
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── in28minutes
│ │ │ └── springboot
│ │ │ └── basics
│ │ │ └── springbootin10steps
│ │ │ ├── Book.java
│ │ │ ├── BooksController.java
│ │ │ └── SpringbootIn10StepsApplication.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── in28minutes
│ └── springboot
│ └── basics
│ └── springbootin10steps
│ └── SpringbootIn10StepsApplicationTests.java
├── 02.Spring-Boot-Web-Application
├── README.md
├── Step01.md
├── Step02.md
├── Step03.md
├── Step04.md
├── Step05.md
├── Step06.md
├── Step07.md
├── Step07.zip
├── Step08.md
├── Step08.zip
├── Step09.md
├── Step10.md
├── Step11.md
├── Step12.md
├── Step12.zip
├── Step13.md
├── Step13.zip
├── Step14.md
├── Step15.md
├── Step15.zip
├── Step16.md
├── Step16.zip
├── Step17.md
├── Step18.md
├── Step18.zip
├── Step19.md
├── Step19.zip
├── Step20.md
├── Step20.zip
├── Step21.md
├── Step21.zip
├── Step22.md
├── Step22.zip
├── Step23.md
├── Step23.zip
├── Step24.md
├── Step25.md
├── Step25.zip
├── Step26.md
├── Step27.md
├── Step27.zip
├── StepReference.md
├── pom.xml
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── in28minutes
│ │ │ │ └── springboot
│ │ │ │ └── web
│ │ │ │ ├── SpringBootFirstWebApplication.java
│ │ │ │ ├── controller
│ │ │ │ ├── ErrorController.java
│ │ │ │ ├── LogoutController.java
│ │ │ │ ├── TodoController.java
│ │ │ │ └── WelcomeController.java
│ │ │ │ ├── model
│ │ │ │ └── Todo.java
│ │ │ │ ├── security
│ │ │ │ └── SecurityConfiguration.java
│ │ │ │ └── service
│ │ │ │ └── TodoService.java
│ │ ├── resources
│ │ │ └── application.properties
│ │ └── webapp
│ │ │ └── WEB-INF
│ │ │ └── jsp
│ │ │ ├── common
│ │ │ ├── footer.jspf
│ │ │ ├── header.jspf
│ │ │ └── navigation.jspf
│ │ │ ├── error.jsp
│ │ │ ├── list-todos.jsp
│ │ │ ├── todo.jsp
│ │ │ └── welcome.jsp
│ └── test
│ │ └── java
│ │ └── com
│ │ └── in28minutes
│ │ └── springboot
│ │ └── web
│ │ └── SpringBootFirstWebApplicationTests.java
└── target
│ └── classes
│ ├── META-INF
│ ├── MANIFEST.MF
│ └── maven
│ │ └── com.in28minutes.springboot.web
│ │ └── spring-boot-first-web-application-git
│ │ ├── pom.properties
│ │ └── pom.xml
│ └── application.properties
├── 03.JUnit-Introduction-In-5-Steps
├── .classpath
├── .gitignore
├── .project
├── code-21July2017.zip
├── readme.md
├── src
│ └── com
│ │ └── in28minutes
│ │ └── junit
│ │ └── MyMath.java
├── step22.md
├── step22.zip
├── step25.md
├── step25.zip
└── test
│ └── com
│ └── in28minutes
│ └── junit
│ ├── AssertTest.java
│ └── MyMathTest.java
├── 04.Mockito-Introduction-In-5-Steps
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── code-21July2017.zip
├── mvnw
├── mvnw.cmd
├── pom.xml
├── readme.md
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── in28minutes
│ │ │ └── mockito
│ │ │ └── mockitodemo
│ │ │ ├── DataService.java
│ │ │ ├── MockitoDemoApplication.java
│ │ │ └── SomeBusinessImpl.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── in28minutes
│ └── mockito
│ └── mockitodemo
│ ├── ListTest.java
│ ├── MockitoDemoApplicationTests.java
│ ├── SomeBusinessMockAnnotationsTest.java
│ ├── SomeBusinessMockTest.java
│ └── SomeBusinessStubTest.java
├── 05.Spring-Boot-Advanced
├── .classpath
├── .project
├── .settings
│ ├── .jsdtscope
│ ├── org.eclipse.core.resources.prefs
│ ├── org.eclipse.jdt.core.prefs
│ ├── org.eclipse.m2e.core.prefs
│ ├── org.eclipse.wst.common.component
│ ├── org.eclipse.wst.common.project.facet.core.xml
│ ├── org.eclipse.wst.jsdt.ui.superType.container
│ ├── org.eclipse.wst.jsdt.ui.superType.name
│ └── org.eclipse.wst.validation.prefs
├── README.md
├── Step01.md
├── Step01.zip
├── Step02.md
├── Step02.zip
├── Step03.md
├── Step04.md
├── Step05.md
├── Step06.md
├── Step06.zip
├── Step07.md
├── Step08.md
├── Step08.zip
├── Step09.md
├── Step10.md
├── Step10.zip
├── Step11.md
├── Step12.md
├── Step13.md
├── Step13.zip
├── Step14.md
├── Step14.zip
├── Step15.md
├── Step15.zip
├── Step16.md
├── Step16.zip
├── Step17.md
├── Step17.zip
├── Step18.md
├── Step18.zip
├── Step19.md
├── Step19.zip
├── Step20.md
├── Step20.zip
├── Step21.md
├── Step21.zip
├── Step22.md
├── Step22.zip
├── Step23.md
├── Step23.zip
├── Step24.md
├── Step25.md
├── Step25.zip
├── Step26.md
├── Step27.md
├── Step27.zip
├── Step28.md
├── Step28.zip
├── StepReference.md
├── pom.xml
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── in28minutes
│ │ │ │ └── springboot
│ │ │ │ ├── Application.java
│ │ │ │ ├── WelcomeController.java
│ │ │ │ ├── WelcomeService.java
│ │ │ │ ├── configuration
│ │ │ │ └── BasicConfiguration.java
│ │ │ │ ├── controller
│ │ │ │ └── SurveyController.java
│ │ │ │ ├── jpa
│ │ │ │ ├── User.java
│ │ │ │ ├── UserCommandLineRunner.java
│ │ │ │ ├── UserRepository.java
│ │ │ │ └── UserRestRepository.java
│ │ │ │ ├── model
│ │ │ │ ├── Question.java
│ │ │ │ └── Survey.java
│ │ │ │ ├── security
│ │ │ │ └── SecurityConfig.java
│ │ │ │ └── service
│ │ │ │ └── SurveyService.java
│ │ └── resources
│ │ │ ├── application-dev.properties
│ │ │ ├── application-prod.properties
│ │ │ └── application.properties
│ └── test
│ │ └── java
│ │ └── com
│ │ └── in28minutes
│ │ └── springboot
│ │ └── controller
│ │ ├── SurveyControllerIT.java
│ │ └── SurveyControllerTest.java
└── target
│ ├── classes
│ ├── META-INF
│ │ ├── MANIFEST.MF
│ │ └── maven
│ │ │ └── com.in28minutes.springboot
│ │ │ └── first-springboot-project
│ │ │ ├── pom.properties
│ │ │ └── pom.xml
│ ├── application-dev.properties
│ ├── application-prod.properties
│ └── application.properties
│ ├── m2e-wtp
│ └── web-resources
│ │ └── META-INF
│ │ ├── MANIFEST.MF
│ │ └── maven
│ │ └── com.in28minutes
│ │ └── springboot-for-beginners-example
│ │ ├── pom.properties
│ │ └── pom.xml
│ ├── maven-status
│ └── maven-compiler-plugin
│ │ ├── compile
│ │ └── default-compile
│ │ │ ├── createdFiles.lst
│ │ │ └── inputFiles.lst
│ │ └── testCompile
│ │ └── default-testCompile
│ │ ├── createdFiles.lst
│ │ └── inputFiles.lst
│ └── surefire-reports
│ ├── TEST-com.in28minutes.springboot.controller.SurveyControllerTest.xml
│ └── com.in28minutes.springboot.controller.SurveyControllerTest.txt
├── 06.JPA-Introduction-In-10-Steps
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── code-21July2017.zip
├── jpa-in-10-steps-all-code.md
├── mvnw
├── mvnw.cmd
├── notes.txt
├── pom.xml
├── readme.md
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── in28minutes
│ │ │ │ └── learning
│ │ │ │ └── jpa
│ │ │ │ └── jpain10steps
│ │ │ │ ├── JpaIn10StepsApplication.java
│ │ │ │ ├── UserDaoServiceCommandLineRunner.java
│ │ │ │ ├── UserRepositoryCommandLineRunner.java
│ │ │ │ ├── entity
│ │ │ │ └── User.java
│ │ │ │ └── service
│ │ │ │ ├── UserDAOService.java
│ │ │ │ └── UserRepository.java
│ │ └── resources
│ │ │ └── application.properties
│ └── test
│ │ └── java
│ │ └── com
│ │ └── in28minutes
│ │ └── learning
│ │ └── jpa
│ │ └── jpain10steps
│ │ └── JpaIn10StepsApplicationTests.java
├── step-completed.sh
├── step21.md
├── step21.zip
├── step22.md
├── step22.zip
├── step23.md
├── step23.zip
└── take-step-backup.sh
├── 09.Spring-Introduction-In-10-Steps
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── code-21July2017.zip
├── mvnw
├── mvnw.cmd
├── pom.xml
├── readme.md
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── in28minutes
│ │ │ └── spring
│ │ │ └── basics
│ │ │ └── springin5steps
│ │ │ ├── BinarySearchImpl.java
│ │ │ ├── BubbleSortAlgorithm.java
│ │ │ ├── QuickSortAlgorithm.java
│ │ │ ├── SortAlgorithm.java
│ │ │ └── SpringIn5StepsApplication.java
│ └── resources
│ │ ├── application.properties
│ │ └── log.txt
│ └── test
│ └── java
│ └── com
│ └── in28minutes
│ └── spring
│ └── basics
│ └── springin5steps
│ └── SpringIn5StepsApplicationTests.java
├── README.md
├── Step01.md
├── Step01.zip
├── Step02.md
├── Step02.zip
├── Step03.md
├── Step04.md
├── Step05.md
├── Step06.md
├── Step06.zip
├── Step07.md
├── Step08.md
├── Step08.zip
├── Step09.md
├── Step10.md
├── Step10.zip
├── Step11.md
├── Step12.md
├── Step13.md
├── Step13.zip
├── Step14.md
├── Step14.zip
├── Step15.md
├── Step15.zip
├── Step16.md
├── Step16.zip
├── Step17.md
├── Step17.zip
├── Step18.md
├── Step18.zip
├── Step19.md
├── Step19.zip
├── Step20.md
├── Step20.zip
├── Step21.md
├── Step21.zip
├── Step22.md
├── Step22.zip
├── Step23.md
├── Step23.zip
├── Step24.md
├── Step25.md
├── Step25.zip
├── Step26.md
├── Step27.md
├── Step27.zip
├── Step28.md
├── Step28.zip
├── StepReference.md
├── pom.xml
└── src
├── main
├── java
│ └── com
│ │ └── in28minutes
│ │ └── springboot
│ │ ├── Application.java
│ │ ├── WelcomeController.java
│ │ ├── WelcomeService.java
│ │ ├── configuration
│ │ └── BasicConfiguration.java
│ │ ├── controller
│ │ └── SurveyController.java
│ │ ├── jpa
│ │ ├── User.java
│ │ ├── UserCommandLineRunner.java
│ │ ├── UserRepository.java
│ │ └── UserRestRepository.java
│ │ ├── model
│ │ ├── Question.java
│ │ └── Survey.java
│ │ ├── security
│ │ └── SecurityConfig.java
│ │ └── service
│ │ └── SurveyService.java
└── resources
│ ├── application-dev.properties
│ ├── application-prod.properties
│ └── application.properties
└── test
└── java
└── com
└── in28minutes
└── springboot
└── controller
├── SurveyControllerIT.java
└── SurveyControllerTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 |
3 | # Mobile Tools for Java (J2ME)
4 | .mtj.tmp/
5 |
6 | # Package Files #
7 | *.jar
8 | *.war
9 | *.ear
10 |
11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
12 | hs_err_pid*
13 |
--------------------------------------------------------------------------------
/01.Spring-Boot-Introduction-In-10-Steps/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/01.Spring-Boot-Introduction-In-10-Steps/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/01.Spring-Boot-Introduction-In-10-Steps/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/01.Spring-Boot-Introduction-In-10-Steps/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/01.Spring-Boot-Introduction-In-10-Steps/code-21July2017.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/01.Spring-Boot-Introduction-In-10-Steps/code-21July2017.zip
--------------------------------------------------------------------------------
/01.Spring-Boot-Introduction-In-10-Steps/notes.txt:
--------------------------------------------------------------------------------
1 | ## Spring Boot
2 |
3 | ### Goals
4 | - Enable building production ready applications quickly
5 | - Provide common non-functional features
6 | - embedded servers
7 | - metrics
8 | - health checks
9 | - externalized configuration
10 |
11 | ### What Spring Boot is NOT!
12 | - ZERO code generation
13 | - Neither an application server nor a web server
14 |
15 | ### Features
16 | - Quick Starter Projects with Auto Configuration
17 | - Web
18 | - JPA
19 | - Embedded Servers - Tomcat, Jetty or Undertow
20 | - Production-ready features
21 | - metrics and health checks
22 | - externalized configuration
23 |
24 |
25 | http://localhost:8080/books => Few hardcoded books
26 |
--------------------------------------------------------------------------------
/01.Spring-Boot-Introduction-In-10-Steps/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.in28minutes.springboot.basics
7 | springboot-in-10-steps
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | springboot-in-10-steps
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.0.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-actuator
36 |
37 |
38 |
39 | org.springframework.data
40 | spring-data-rest-hal-browser
41 |
42 |
43 |
49 |
50 |
51 | org.springframework.boot
52 | spring-boot-starter-test
53 | test
54 |
55 |
56 |
57 | org.springframework.boot
58 | spring-boot-devtools
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | org.springframework.boot
67 | spring-boot-maven-plugin
68 |
69 |
70 |
71 |
72 |
73 |
74 | spring-snapshots
75 | Spring Snapshots
76 | https://repo.spring.io/snapshot
77 |
78 | true
79 |
80 |
81 |
82 | spring-milestones
83 | Spring Milestones
84 | https://repo.spring.io/milestone
85 |
86 | false
87 |
88 |
89 |
90 |
91 |
92 |
93 | spring-snapshots
94 | Spring Snapshots
95 | https://repo.spring.io/snapshot
96 |
97 | true
98 |
99 |
100 |
101 | spring-milestones
102 | Spring Milestones
103 | https://repo.spring.io/milestone
104 |
105 | false
106 |
107 |
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/01.Spring-Boot-Introduction-In-10-Steps/src/main/java/com/in28minutes/springboot/basics/springbootin10steps/Book.java:
--------------------------------------------------------------------------------
1 | package com.in28minutes.springboot.basics.springbootin10steps;
2 |
3 | public class Book {
4 | long id;
5 | String name;
6 | String author;
7 |
8 | public Book(long id, String name, String author) {
9 | super();
10 | this.id = id;
11 | this.name = name;
12 | this.author = author;
13 | }
14 |
15 | public long getId() {
16 | return id;
17 | }
18 |
19 | public String getName() {
20 | return name;
21 | }
22 |
23 | public String getAuthor() {
24 | return author;
25 | }
26 |
27 | @Override
28 | public String toString() {
29 | return String.format("Book [id=%s, name=%s, author=%s]", id, name, author);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/01.Spring-Boot-Introduction-In-10-Steps/src/main/java/com/in28minutes/springboot/basics/springbootin10steps/BooksController.java:
--------------------------------------------------------------------------------
1 | package com.in28minutes.springboot.basics.springbootin10steps;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | import org.springframework.web.bind.annotation.GetMapping;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | @RestController
10 | public class BooksController {
11 | @GetMapping("/books")
12 | public List getAllBooks() {
13 | return Arrays.asList(
14 | new Book(1l, "Mastering Spring 5.2", "Ranga Karanam"));
15 | }
16 | }
--------------------------------------------------------------------------------
/01.Spring-Boot-Introduction-In-10-Steps/src/main/java/com/in28minutes/springboot/basics/springbootin10steps/SpringbootIn10StepsApplication.java:
--------------------------------------------------------------------------------
1 | package com.in28minutes.springboot.basics.springbootin10steps;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.context.ApplicationContext;
6 | import org.springframework.context.ConfigurableApplicationContext;
7 |
8 | @SpringBootApplication
9 | public class SpringbootIn10StepsApplication {
10 |
11 | public static void main(String[] args) {
12 | ApplicationContext applicationContext =
13 | SpringApplication.run(SpringbootIn10StepsApplication.class, args);
14 |
15 | for (String name : applicationContext.getBeanDefinitionNames()) {
16 | System.out.println(name);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/01.Spring-Boot-Introduction-In-10-Steps/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #logging.level.org.springframework = DEBUG
2 | management.security.enabled=false
--------------------------------------------------------------------------------
/01.Spring-Boot-Introduction-In-10-Steps/src/test/java/com/in28minutes/springboot/basics/springbootin10steps/SpringbootIn10StepsApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.in28minutes.springboot.basics.springbootin10steps;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootIn10StepsApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step01.md:
--------------------------------------------------------------------------------
1 | ## What You Will Learn during this Step:
2 | - Lets create a simple web application using Spring Boot
3 | - Lets run the Spring Boot Application
4 | - There is a lot of magic happening in here! We will take a deep dive into the magic in Step 03.
5 |
6 | ## Files List
7 |
8 | ### pom.xml
9 |
10 | ```xml
11 |
12 |
14 | 4.0.0
15 |
16 | com.in28minutes.springboot.web
17 | spring-boot-first-web-application
18 | 0.0.1-SNAPSHOT
19 | jar
20 |
21 | spring-boot-first-web-application
22 | Demo project for Spring Boot
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-starter-parent
27 | 1.4.3.RELEASE
28 |
29 |
30 |
31 |
32 | UTF-8
33 | UTF-8
34 | 1.8
35 |
36 |
37 |
38 |
39 | org.springframework.boot
40 | spring-boot-starter-web
41 |
42 |
43 | org.springframework.boot
44 | spring-boot-devtools
45 | runtime
46 |
47 |
48 | org.springframework.boot
49 | spring-boot-starter-test
50 | test
51 |
52 |
53 |
54 |
55 |
56 |
57 | org.springframework.boot
58 | spring-boot-maven-plugin
59 |
60 |
61 |
62 |
63 |
64 | ```
65 | ---
66 | ### src/main/java/com/in28minutes/springboot/web/SpringBootFirstWebApplication.java
67 |
68 | ```java
69 | package com.in28minutes.springboot.web;
70 |
71 | import org.springframework.boot.SpringApplication;
72 | import org.springframework.boot.autoconfigure.SpringBootApplication;
73 |
74 | @SpringBootApplication
75 | public class SpringBootFirstWebApplication {
76 |
77 | public static void main(String[] args) {
78 | SpringApplication.run(SpringBootFirstWebApplication.class, args);
79 | }
80 | }
81 | ```
82 | ---
83 | ### src/main/resources/application.properties
84 |
85 | ```
86 | ```
87 | ---
88 | ### src/test/java/com/in28minutes/springboot/web/SpringBootFirstWebApplicationTests.java
89 |
90 | ```java
91 | package com.in28minutes.springboot.web;
92 |
93 | import org.junit.Test;
94 | import org.junit.runner.RunWith;
95 | import org.springframework.boot.test.context.SpringBootTest;
96 | import org.springframework.test.context.junit4.SpringRunner;
97 |
98 | @RunWith(SpringRunner.class)
99 | @SpringBootTest
100 | public class SpringBootFirstWebApplicationTests {
101 |
102 | @Test
103 | public void contextLoads() {
104 | }
105 |
106 | }
107 | ```
108 | ---
109 | ### todo.txt
110 |
111 | ```
112 | Spring Boot Starter Parent
113 | Spring Boot Starter Web
114 | @SpringBootApplication
115 | Auto Configuration
116 | ```
117 | ---
118 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step03.md:
--------------------------------------------------------------------------------
1 | ## What You Will Learn during this Step:
2 | - Demystifying some of the magic
3 | - Spring Boot Starter Parent
4 | - Spring Boot Starter Web
5 | - Embedded Tomcat
6 | - Dev Tools
7 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step06.md:
--------------------------------------------------------------------------------
1 | ## What You Will Learn during this Step:
2 | - Understand importance of DispatcherServlet.
3 |
4 | ## Spring MVC Request Flow
5 | - DispatcherServlet receives HTTP Request.
6 | - DispatcherServlet identifies the right Controller based on the URL.
7 | - Controller executes Business Logic.
8 | - Controller returns a) Model b) View Name Back to DispatcherServlet.
9 | - DispatcherServlet identifies the correct view (ViewResolver).
10 | - DispatcherServlet makes the model available to view and executes it.
11 | - DispatcherServlet returns HTTP Response Back.
12 | - Flow : http://docs.spring.io/spring-framework/docs/2.0.8/reference/images/mvc.png
13 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step07.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/02.Spring-Boot-Web-Application/Step07.zip
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step08.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/02.Spring-Boot-Web-Application/Step08.zip
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step09.md:
--------------------------------------------------------------------------------
1 | ## What You Will Learn during this Step:
2 | - Magic of Spring
3 | - Learn about Spring Auto-wiring and Dependency Management.
4 | - @Autowired, @Component
5 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step11.md:
--------------------------------------------------------------------------------
1 | ## What we will do:
2 | - Lets discuss about Architecture of web applications
3 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step12.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/02.Spring-Boot-Web-Application/Step12.zip
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step13.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/02.Spring-Boot-Web-Application/Step13.zip
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step14.md:
--------------------------------------------------------------------------------
1 | ## What we will do:
2 | - Display Todos in a table using JSTL Tags
3 | - <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
4 | - Add Dependency for jstl
5 |
6 | ## Snippet
7 | ```
8 |
9 | javax.servlet
10 | jstl
11 |
12 | ```
13 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step15.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/02.Spring-Boot-Web-Application/Step15.zip
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step16.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/02.Spring-Boot-Web-Application/Step16.zip
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step18.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/02.Spring-Boot-Web-Application/Step18.zip
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step19.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/02.Spring-Boot-Web-Application/Step19.zip
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step20.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/02.Spring-Boot-Web-Application/Step20.zip
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step21.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/02.Spring-Boot-Web-Application/Step21.zip
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step22.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/02.Spring-Boot-Web-Application/Step22.zip
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step23.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/02.Spring-Boot-Web-Application/Step23.zip
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step24.md:
--------------------------------------------------------------------------------
1 | ## What we will do:
2 | - Remove Hardcoding of User Name
3 | - Remove LoginService
4 | - Rename LoginController to WelcomeController
5 | - Add Logout Functionality
6 |
7 | ## Useful Snippets
8 | ```
9 | private String getLoggedInUserName(ModelMap model) {
10 | Object principal = SecurityContextHolder.getContext()
11 | .getAuthentication().getPrincipal();
12 |
13 | if (principal instanceof UserDetails)
14 | return ((UserDetails) principal).getUsername();
15 |
16 | return principal.toString();
17 | }
18 |
19 |
22 |
23 | @RequestMapping(value = "/logout", method = RequestMethod.GET)
24 | public String logout(HttpServletRequest request,
25 | HttpServletResponse response) {
26 | Authentication auth = SecurityContextHolder.getContext()
27 | .getAuthentication();
28 | if (auth != null) {
29 | new SecurityContextLogoutHandler().logout(request, response, auth);
30 | }
31 | return "redirect:/";
32 | }
33 |
34 | ```
35 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step25.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/02.Spring-Boot-Web-Application/Step25.zip
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step27.md:
--------------------------------------------------------------------------------
1 | ## What we will do:
2 | - One More Spring Rest Services.
3 | - @PathVariable("id") int id
4 | - http://localhost:8080/rest/todos/1
5 |
6 | ## Useful Snippets
7 |
8 | ```
9 | @RequestMapping(value = "/rest/todos/{id}", method = RequestMethod.GET)
10 | public Todo retrieveTodo(@PathVariable("id") int id) {
11 | return service.retrieveTodo(id);
12 | }
13 |
14 | ```
15 | ## Files List
16 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/Step27.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/in28minutes/SpringBootForBeginners/96aac7f51218090c1fa45747b9b48de5e0faabac/02.Spring-Boot-Web-Application/Step27.zip
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/StepReference.md:
--------------------------------------------------------------------------------
1 | ## What You Will Learn during this Step:
2 | - First
3 | - Second
4 | - Third
5 |
6 | ## Useful Snippets and References
7 | First Snippet
8 | ```
9 | ```
10 | Second Snippet
11 | ```
12 | ```
13 |
14 | ## Exercises
15 |
16 | ## Files List
17 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.in28minutes.springboot.web
7 | spring-boot-first-web-application-git
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | spring-boot-first-web-application
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.4.3.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 |
37 |
38 |
39 | javax.servlet
40 | jstl
41 |
42 |
43 |
44 | org.webjars
45 | bootstrap
46 | 3.3.6
47 |
48 |
49 |
50 | org.webjars
51 | bootstrap-datepicker
52 | 1.0.1
53 |
54 |
55 |
56 | org.webjars
57 | jquery
58 | 1.9.1
59 |
60 |
61 |
62 | org.apache.tomcat.embed
63 | tomcat-embed-jasper
64 | provided
65 |
66 |
67 |
68 | org.springframework.boot
69 | spring-boot-devtools
70 | runtime
71 |
72 |
73 |
74 | org.springframework.boot
75 | spring-boot-starter-test
76 | test
77 |
78 |
79 |
80 |
81 |
82 |
83 | org.springframework.boot
84 | spring-boot-maven-plugin
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/src/main/java/com/in28minutes/springboot/web/SpringBootFirstWebApplication.java:
--------------------------------------------------------------------------------
1 | package com.in28minutes.springboot.web;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.context.annotation.ComponentScan;
6 |
7 | @SpringBootApplication
8 | @ComponentScan("com.in28minutes.springboot.web")
9 | public class SpringBootFirstWebApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringBootFirstWebApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/src/main/java/com/in28minutes/springboot/web/controller/ErrorController.java:
--------------------------------------------------------------------------------
1 | package com.in28minutes.springboot.web.controller;
2 |
3 | import javax.servlet.http.HttpServletRequest;
4 | import javax.servlet.http.HttpServletResponse;
5 |
6 | import org.springframework.stereotype.Controller;
7 | import org.springframework.web.bind.annotation.ExceptionHandler;
8 | import org.springframework.web.servlet.ModelAndView;
9 |
10 | @Controller("error")
11 | public class ErrorController {
12 |
13 | @ExceptionHandler(Exception.class)
14 | public ModelAndView handleException
15 | (HttpServletRequest request, Exception ex){
16 | ModelAndView mv = new ModelAndView();
17 |
18 | mv.addObject("exception", ex.getLocalizedMessage());
19 | mv.addObject("url", request.getRequestURL());
20 |
21 | mv.setViewName("error");
22 | return mv;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/src/main/java/com/in28minutes/springboot/web/controller/LogoutController.java:
--------------------------------------------------------------------------------
1 | package com.in28minutes.springboot.web.controller;
2 |
3 | import javax.servlet.http.HttpServletRequest;
4 | import javax.servlet.http.HttpServletResponse;
5 |
6 | import org.springframework.security.core.Authentication;
7 | import org.springframework.security.core.context.SecurityContextHolder;
8 | import org.springframework.security.core.userdetails.UserDetails;
9 | import org.springframework.security.web.authentication.logout.LogoutHandler;
10 | import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
11 | import org.springframework.stereotype.Controller;
12 | import org.springframework.ui.ModelMap;
13 | import org.springframework.web.bind.annotation.RequestMapping;
14 | import org.springframework.web.bind.annotation.RequestMethod;
15 |
16 | @Controller
17 | public class LogoutController {
18 |
19 | @RequestMapping(value = "/logout", method = RequestMethod.GET)
20 | public String logout(HttpServletRequest request,
21 | HttpServletResponse response) {
22 |
23 | Authentication authentication = SecurityContextHolder.getContext()
24 | .getAuthentication();
25 |
26 | if (authentication != null) {
27 | new SecurityContextLogoutHandler().logout(request, response,
28 | authentication);
29 | }
30 |
31 | return "redirect:/";
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/src/main/java/com/in28minutes/springboot/web/controller/TodoController.java:
--------------------------------------------------------------------------------
1 | package com.in28minutes.springboot.web.controller;
2 |
3 | import java.text.SimpleDateFormat;
4 | import java.util.Date;
5 |
6 | import javax.validation.Valid;
7 |
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.beans.propertyeditors.CustomDateEditor;
10 | import org.springframework.security.core.context.SecurityContextHolder;
11 | import org.springframework.security.core.userdetails.UserDetails;
12 | import org.springframework.stereotype.Controller;
13 | import org.springframework.ui.ModelMap;
14 | import org.springframework.validation.BindingResult;
15 | import org.springframework.web.bind.WebDataBinder;
16 | import org.springframework.web.bind.annotation.InitBinder;
17 | import org.springframework.web.bind.annotation.RequestMapping;
18 | import org.springframework.web.bind.annotation.RequestMethod;
19 | import org.springframework.web.bind.annotation.RequestParam;
20 |
21 | import com.in28minutes.springboot.web.model.Todo;
22 | import com.in28minutes.springboot.web.service.TodoService;
23 |
24 | @Controller
25 | public class TodoController {
26 |
27 | @Autowired
28 | TodoService service;
29 |
30 | @InitBinder
31 | public void initBinder(WebDataBinder binder) {
32 | // Date - dd/MM/yyyy
33 | SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
34 | binder.registerCustomEditor(Date.class, new CustomDateEditor(
35 | dateFormat, false));
36 | }
37 |
38 | @RequestMapping(value = "/list-todos", method = RequestMethod.GET)
39 | public String showTodos(ModelMap model) {
40 | String name = getLoggedInUserName(model);
41 | model.put("todos", service.retrieveTodos(name));
42 | return "list-todos";
43 | }
44 |
45 | private String getLoggedInUserName(ModelMap model) {
46 | Object principal = SecurityContextHolder.getContext()
47 | .getAuthentication().getPrincipal();
48 |
49 | if (principal instanceof UserDetails) {
50 | return ((UserDetails) principal).getUsername();
51 | }
52 |
53 | return principal.toString();
54 | }
55 |
56 | @RequestMapping(value = "/add-todo", method = RequestMethod.GET)
57 | public String showAddTodoPage(ModelMap model) {
58 | model.addAttribute("todo", new Todo(0, getLoggedInUserName(model),
59 | "Default Desc", new Date(), false));
60 | return "todo";
61 | }
62 |
63 | @RequestMapping(value = "/delete-todo", method = RequestMethod.GET)
64 | public String deleteTodo(@RequestParam int id) {
65 |
66 | if(id==1)
67 | throw new RuntimeException("Something went wrong");
68 |
69 | service.deleteTodo(id);
70 | return "redirect:/list-todos";
71 | }
72 |
73 | @RequestMapping(value = "/update-todo", method = RequestMethod.GET)
74 | public String showUpdateTodoPage(@RequestParam int id, ModelMap model) {
75 | Todo todo = service.retrieveTodo(id);
76 | model.put("todo", todo);
77 | return "todo";
78 | }
79 |
80 | @RequestMapping(value = "/update-todo", method = RequestMethod.POST)
81 | public String updateTodo(ModelMap model, @Valid Todo todo,
82 | BindingResult result) {
83 |
84 | if (result.hasErrors()) {
85 | return "todo";
86 | }
87 |
88 | todo.setUser(getLoggedInUserName(model));
89 |
90 | service.updateTodo(todo);
91 |
92 | return "redirect:/list-todos";
93 | }
94 |
95 | @RequestMapping(value = "/add-todo", method = RequestMethod.POST)
96 | public String addTodo(ModelMap model, @Valid Todo todo, BindingResult result) {
97 |
98 | if (result.hasErrors()) {
99 | return "todo";
100 | }
101 |
102 | service.addTodo(getLoggedInUserName(model), todo.getDesc(), todo.getTargetDate(),
103 | false);
104 | return "redirect:/list-todos";
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/src/main/java/com/in28minutes/springboot/web/controller/WelcomeController.java:
--------------------------------------------------------------------------------
1 | package com.in28minutes.springboot.web.controller;
2 |
3 | import org.springframework.security.core.context.SecurityContextHolder;
4 | import org.springframework.security.core.userdetails.UserDetails;
5 | import org.springframework.stereotype.Controller;
6 | import org.springframework.ui.ModelMap;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestMethod;
9 |
10 | @Controller
11 | public class WelcomeController {
12 |
13 | @RequestMapping(value = "/", method = RequestMethod.GET)
14 | public String showWelcomePage(ModelMap model) {
15 | model.put("name", getLoggedinUserName());
16 | return "welcome";
17 | }
18 |
19 | private String getLoggedinUserName() {
20 | Object principal = SecurityContextHolder.getContext()
21 | .getAuthentication().getPrincipal();
22 |
23 | if (principal instanceof UserDetails) {
24 | return ((UserDetails) principal).getUsername();
25 | }
26 |
27 | return principal.toString();
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/src/main/java/com/in28minutes/springboot/web/model/Todo.java:
--------------------------------------------------------------------------------
1 | package com.in28minutes.springboot.web.model;
2 |
3 | import java.util.Date;
4 |
5 | import javax.validation.constraints.Size;
6 |
7 | public class Todo {
8 | private int id;
9 | private String user;
10 |
11 | @Size(min=10, message="Enter at least 10 Characters...")
12 | private String desc;
13 |
14 | private Date targetDate;
15 | private boolean isDone;
16 |
17 | public Todo() {
18 | super();
19 | }
20 |
21 | public Todo(int id, String user, String desc, Date targetDate,
22 | boolean isDone) {
23 | super();
24 | this.id = id;
25 | this.user = user;
26 | this.desc = desc;
27 | this.targetDate = targetDate;
28 | this.isDone = isDone;
29 | }
30 |
31 | public int getId() {
32 | return id;
33 | }
34 |
35 | public void setId(int id) {
36 | this.id = id;
37 | }
38 |
39 | public String getUser() {
40 | return user;
41 | }
42 |
43 | public void setUser(String user) {
44 | this.user = user;
45 | }
46 |
47 | public String getDesc() {
48 | return desc;
49 | }
50 |
51 | public void setDesc(String desc) {
52 | this.desc = desc;
53 | }
54 |
55 | public Date getTargetDate() {
56 | return targetDate;
57 | }
58 |
59 | public void setTargetDate(Date targetDate) {
60 | this.targetDate = targetDate;
61 | }
62 |
63 | public boolean isDone() {
64 | return isDone;
65 | }
66 |
67 | public void setDone(boolean isDone) {
68 | this.isDone = isDone;
69 | }
70 |
71 | @Override
72 | public int hashCode() {
73 | final int prime = 31;
74 | int result = 1;
75 | result = prime * result + id;
76 | return result;
77 | }
78 |
79 | @Override
80 | public boolean equals(Object obj) {
81 | if (this == obj) {
82 | return true;
83 | }
84 | if (obj == null) {
85 | return false;
86 | }
87 | if (getClass() != obj.getClass()) {
88 | return false;
89 | }
90 | Todo other = (Todo) obj;
91 | if (id != other.id) {
92 | return false;
93 | }
94 | return true;
95 | }
96 |
97 | @Override
98 | public String toString() {
99 | return String.format(
100 | "Todo [id=%s, user=%s, desc=%s, targetDate=%s, isDone=%s]", id,
101 | user, desc, targetDate, isDone);
102 | }
103 |
104 | }
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/src/main/java/com/in28minutes/springboot/web/security/SecurityConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.in28minutes.springboot.web.security;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
6 | import org.springframework.security.config.annotation.web.builders.HttpSecurity;
7 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
8 |
9 | @Configuration
10 | public class SecurityConfiguration extends WebSecurityConfigurerAdapter{
11 | //Create User - in28Minutes/dummy
12 | @Autowired
13 | public void configureGlobalSecurity(AuthenticationManagerBuilder auth)
14 | throws Exception {
15 | auth.inMemoryAuthentication().passwordEncoder(org.springframework.security.crypto.password.NoOpPasswordEncoder.getInstance()).withUser("in28Minutes").password("dummy")
16 | .roles("USER", "ADMIN");
17 | }
18 |
19 | @Override
20 | protected void configure(HttpSecurity http) throws Exception {
21 | http.authorizeRequests().antMatchers("/login").permitAll()
22 | .antMatchers("/", "/*todo*/**").access("hasRole('USER')").and()
23 | .formLogin();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/src/main/java/com/in28minutes/springboot/web/service/TodoService.java:
--------------------------------------------------------------------------------
1 | package com.in28minutes.springboot.web.service;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Date;
5 | import java.util.Iterator;
6 | import java.util.List;
7 |
8 | import org.springframework.stereotype.Service;
9 |
10 | import com.in28minutes.springboot.web.model.Todo;
11 |
12 | @Service
13 | public class TodoService {
14 | private static List todos = new ArrayList();
15 | private static int todoCount = 3;
16 |
17 | static {
18 | todos.add(new Todo(1, "in28Minutes", "Learn Spring MVC", new Date(),
19 | false));
20 | todos.add(new Todo(2, "in28Minutes", "Learn Struts", new Date(), false));
21 | todos.add(new Todo(3, "in28Minutes", "Learn Hibernate", new Date(),
22 | false));
23 | }
24 |
25 | public List retrieveTodos(String user) {
26 | List filteredTodos = new ArrayList();
27 | for (Todo todo : todos) {
28 | if (todo.getUser().equalsIgnoreCase(user)) {
29 | filteredTodos.add(todo);
30 | }
31 | }
32 | return filteredTodos;
33 | }
34 |
35 | public Todo retrieveTodo(int id) {
36 | for (Todo todo : todos) {
37 | if (todo.getId()==id) {
38 | return todo;
39 | }
40 | }
41 | return null;
42 | }
43 |
44 | public void updateTodo(Todo todo){
45 | todos.remove(todo);
46 | todos.add(todo);
47 | }
48 |
49 | public void addTodo(String name, String desc, Date targetDate,
50 | boolean isDone) {
51 | todos.add(new Todo(++todoCount, name, desc, targetDate, isDone));
52 | }
53 |
54 | public void deleteTodo(int id) {
55 | Iterator iterator = todos.iterator();
56 | while (iterator.hasNext()) {
57 | Todo todo = iterator.next();
58 | if (todo.getId() == id) {
59 | iterator.remove();
60 | }
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.mvc.view.prefix=/WEB-INF/jsp/
2 | spring.mvc.view.suffix=.jsp
3 | logging.level.org.springframework.web=INFO
--------------------------------------------------------------------------------
/02.Spring-Boot-Web-Application/src/main/webapp/WEB-INF/jsp/common/footer.jspf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
10 |
11 |