Skip to content

Commit 93489f2

Browse files
Ranga Rao KaranamRanga Rao Karanam
authored andcommitted
Small Updates
1 parent c87d7bb commit 93489f2

File tree

4 files changed

+104
-107
lines changed

4 files changed

+104
-107
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ You will learn about
3535
- Basics of Auto Configuration and Spring Boot Magic
3636
- Spring Boot Starter Projects
3737
- Spring Initializr
38-
- Basic REST Services using Spring Boot Data Web
38+
- Basic REST Services using Spring Boot Starter Web
3939
- REST Service Content Negotiation with JSON and XML
4040
- Embedded servlet containers : Tomcat, Jetty and Undertow
4141
- Writing Unit and Integration tests using Spring Boot Starter Test

Step01.md

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
##What You Will Learn during this Step:
22
- Set up an Maven Project with Eclipse.
33
- Intellij Link : https://www.jetbrains.com/help/idea/2016.2/getting-started-with-maven.html#create_maven_project
4-
- Include dependencies needed for Spring Boot.
5-
- spring-boot-starter-web : starter for building applications with Spring MVC. Tomcat is default embedded container.
6-
- spring-boot-maven-plugin : Enable running application in-place and also building a jar/war to run later!
4+
- Copy Two Files pom.xml and Application.java
75
- Launch Your First Spring Boot Application.
8-
9-
###Typical stuff done at the start of projects
10-
- Framework setup
11-
- Identifying compatible framework versions. for example, Which version of Spring and Hibernate to use?
12-
- Configuring (Integrating) frameworks
13-
- Configuring web.xml, Configuring Dispatcher Servlet
14-
- Configuring data source, session factory
15-
- Logging, Transaction Management, Error Handling
16-
- Configuration Management
17-
- Configuring Servers to deploy applications to
18-
- Monitoring Applications
6+
- You will be introduced to Maven
7+
- Dependency Management
198

209
##Cool thing to note!
2110
- Without a lot of configuration, we are up and running with a web application
22-
- 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!
11+
- Refer https://github.com/in28minutes/SpringMvcStepByStep/blob/master/Step15.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!
2312

2413
##What You Will NOT Learn during this Step:
2514
- 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.

Step02.md

Lines changed: 71 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,41 @@
11
##What You Will Learn during this Step:
22
- Lets add a RestController with a dependency and see Spring Boot Magic live
33

4-
##Quick Spring and Spring MVC Primer
4+
##Theory Break : Quick Spring and Spring MVC Primer
55
- What is dependency?
66
- @Component
77
- @Autowired
88
- @RestController
99

1010
## Useful Snippets and References
1111

12-
First Snippet
13-
14-
```
15-
@RestController
16-
class SomeBean {
17-
18-
@Autowired
19-
private SomeDependency someDependency;
20-
21-
@RequestMapping("/")
22-
public String index() {
23-
return someDependency.getSomething();
24-
}
25-
26-
}
27-
28-
@Component
29-
class SomeDependency {
30-
31-
public String getSomething() {
32-
return "Hello! Welcome!";
33-
}
34-
35-
}
36-
37-
```
3812

3913
## Files List
4014
### /pom.xml
4115
```
4216
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
43-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44-
<modelVersion>4.0.0</modelVersion>
45-
<groupId>com.in28minutes</groupId>
46-
<artifactId>springboot-for-beginners-example</artifactId>
47-
<version>0.0.1-SNAPSHOT</version>
48-
<name>Your First Spring Boot Example</name>
49-
<packaging>jar</packaging>
50-
51-
<parent>
52-
<groupId>org.springframework.boot</groupId>
53-
<artifactId>spring-boot-starter-parent</artifactId>
54-
<version>1.4.0.RELEASE</version>
55-
</parent>
56-
57-
<dependencies>
58-
<dependency>
59-
<groupId>org.springframework.boot</groupId>
60-
<artifactId>spring-boot-starter-web</artifactId>
61-
</dependency>
62-
</dependencies>
17+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
18+
<modelVersion>4.0.0</modelVersion>
19+
<groupId>com.in28minutes.springboot</groupId>
20+
<artifactId>first-springboot-project</artifactId>
21+
<version>0.0.1-SNAPSHOT</version>
6322
6423
<properties>
6524
<java.version>1.8</java.version>
6625
</properties>
26+
27+
<parent>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-parent</artifactId>
30+
<version>1.4.0.RELEASE</version>
31+
</parent>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-starter-web</artifactId>
37+
</dependency>
38+
</dependencies>
6739
6840
<build>
6941
<plugins>
@@ -73,49 +45,72 @@ First Snippet
7345
</plugin>
7446
</plugins>
7547
</build>
48+
7649
</project>
50+
51+
52+
53+
54+
55+
```
56+
### /src/main/java/com/in28minutes/service/WelcomeService.java
57+
```
58+
package com.in28minutes.service;
59+
60+
import org.springframework.stereotype.Component;
61+
62+
//Spring to manage this bean and create an instance of this
63+
@Component
64+
public class WelcomeService{
65+
public String retrieveWelcomeMessage() {
66+
//Complex Method
67+
return "Good Morning updated! ";
68+
}
69+
}
7770
```
7871
### /src/main/java/com/in28minutes/springboot/Application.java
7972
```
8073
package com.in28minutes.springboot;
8174
82-
import org.springframework.beans.factory.annotation.Autowired;
8375
import org.springframework.boot.SpringApplication;
8476
import org.springframework.boot.autoconfigure.SpringBootApplication;
8577
import org.springframework.context.ApplicationContext;
86-
import org.springframework.stereotype.Component;
87-
import org.springframework.web.bind.annotation.RequestMapping;
88-
import org.springframework.web.bind.annotation.RestController;
78+
import org.springframework.context.annotation.ComponentScan;
8979
9080
@SpringBootApplication
81+
@ComponentScan("com.in28minutes")
9182
public class Application {
9283
93-
public static void main(String[] args) {
94-
ApplicationContext ctx = SpringApplication.run(Application.class, args);
95-
96-
}
97-
98-
@RestController
99-
class SomeBean {
100-
101-
@Autowired
102-
private SomeDependency someDependency;
103-
104-
@RequestMapping("/")
105-
public String index() {
106-
return someDependency.getSomething();
107-
}
108-
109-
}
84+
public static void main(String[] args) {
85+
ApplicationContext ctx = SpringApplication.run(Application.class, args);
86+
for (int i = 0; i < 10; i++)
87+
System.out.println("");
88+
}
11089
111-
@Component
112-
class SomeDependency {
113-
114-
public String getSomething() {
115-
return "Hello! Welcome!";
116-
}
90+
}
91+
```
92+
### /src/main/java/com/in28minutes/springboot/WelcomeController.java
93+
```
94+
package com.in28minutes.springboot;
11795
118-
}
96+
import org.springframework.beans.factory.annotation.Autowired;
97+
import org.springframework.context.annotation.ComponentScan;
98+
import org.springframework.web.bind.annotation.RequestMapping;
99+
import org.springframework.web.bind.annotation.RestController;
119100
101+
import com.in28minutes.service.WelcomeService;
102+
103+
@RestController
104+
public class WelcomeController {
105+
106+
//Auto wiring
107+
@Autowired
108+
private WelcomeService service;
109+
110+
@RequestMapping("/welcome")
111+
public String welcome() {
112+
return service.retrieveWelcomeMessage();
113+
}
120114
}
121-
```
115+
116+
```

Step05.md

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,45 @@
11
##What You Will Learn during this Step:
22
- Spring Boot vs Spring
33
- What Spring Boot is Not!
4-
- Auto component scan
5-
- A programming tip
6-
- Pair Program once in a while!
74

85
##Spring Boot vs Spring
9-
###Spring
10-
Spring is just a dependency management framework. Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.
6+
7+
### Spring
8+
- Spring is just a dependency injection framework. Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.
9+
- First half of the 2000 decade! EJBs
10+
- EJBs were NOT easy to develop.
11+
- Write a lot of xml and plumbing code to get EJBs running
12+
- Impossible to Unit Test
13+
- Alternative - Writing simple JDBC Code involved a lot of plumbing
14+
- Spring framework started with aim of making Java EE development simpler.
1115
- Goals
1216
- Make applications testable. i.e. easier to write unit tests
1317
- Reduce plumbing code of JDBC and JMS
1418
- Simple architecture. Minus EJB.
1519
- Integrates well with other popular frameworks.
1620

17-
###My experience with Spring based Applications
18-
- Developing Spring Based application need configuration of a lot of beans!
19-
- Integration with other frameworks need configuration as well!
20-
- Added to these, applications need other features (logging, transaction management, monitoring, configuration management etc) before they can go live!
21-
- Spring Boot solves these problems
22-
23-
###Spring Boot
24-
- Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”. Most Spring Boot applications need very little Spring configuration.
25-
- Goals
21+
### Applications with Spring Framework
22+
- Over the next few years, a number of applications were developed with Spring Framework
23+
- Testable but
24+
- Lot of configuration (XML and Java)
25+
- Developing Spring Based application need configuration of a lot of beans!
26+
- Integration with other frameworks need configuration as well!
27+
- In the last few years, focus is moving from monolith applications to microservices. We need to be able to start project quickly. Minimum or Zero start up time
28+
- Framework Setup
29+
- Deployment - Configurability
30+
- Logging, Transaction Management
31+
- Monitoring
32+
- Web Server Configuration
33+
34+
### Spring Boot
35+
- Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”.
36+
- We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss.
37+
- Example Problem Statements
38+
- You want to add Hibernate to your project. You dont worry about configuring a data source and a session factory. I will do if for you!
39+
- Goals
2640
- Provide quick start for projects with Spring.
2741
- Be opinionated but provide options.
2842
- Provide a range of non-functional features that are common to large classes of projects (e.g. embedded servers, security, metrics, health checks, externalized configuration).
29-
- Absolutely no code generation and no requirement for XML configuration.
3043

3144
####What Spring Boot is NOT?
3245
- It’s not an app or a web server

0 commit comments

Comments
 (0)