Skip to content

Commit fc52005

Browse files
author
liqiangqiang
committed
Spring Boot 入门、Spring Boot 配置、Web 开发、模板引擎、数据存储、数据缓存 案例更新
1 parent c862ecd commit fc52005

File tree

70 files changed

+2201
-293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2201
-293
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ Web Flux 努力进行中,尽情期待。唯一文章入口:[GitChat文章地
3333
## 一、项目结构
3434
「Spring Boot 那些事」:[传送门](http://www.bysocket.com/?page_id=1639 "Spring Boot 那些事")<br>
3535

36+
### 『 WebFlux 篇 』
37+
38+
WebFlux 系类文章入口:[GitChat文章地址](http://gitbook.cn/gitchat/author/58968d35f2b669527d7a7c57 "gitchat")
39+
40+
- springboot-webflux <br>
41+
Spring Boot WebFlux 实现 Restful 服务
42+
43+
3644
#### a. 『 基础 - 入门篇 』
3745
- springboot-helloworld<br>
3846
[《Spring Boot 之 HelloWorld 详解》](http://www.bysocket.com/?p=1124 "Spring Boot 之 HelloWorld详解")<br>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<name>chapter-1-spring-boot-quickstart</name>
6+
<description>《Spring Boot 2.x 核心技术实战 - 上 基础篇》第 1 章《Spring Boot 入门》Demo</description>
7+
8+
<groupId>demo.springboot</groupId>
9+
<artifactId>chapter-1-spring-boot-quickstart</artifactId>
10+
<version>1.0</version>
11+
<packaging>jar</packaging>
12+
13+
<parent>
14+
<groupId>org.springframework.boot</groupId>
15+
<artifactId>spring-boot-starter-parent</artifactId>
16+
<version>1.5.1.RELEASE</version>
17+
</parent>
18+
19+
<properties>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
22+
<java.version>1.8</java.version>
23+
</properties>
24+
25+
<dependencies>
26+
27+
<!-- Web 依赖 -->
28+
<dependency>
29+
<groupId>org.springframework.boot</groupId>
30+
<artifactId>spring-boot-starter-web</artifactId>
31+
</dependency>
32+
33+
<!-- 测试依赖 -->
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-starter-test</artifactId>
37+
<scope>test</scope>
38+
</dependency>
39+
40+
</dependencies>
41+
42+
<build>
43+
<plugins>
44+
<!-- Spring Boot Maven 插件 -->
45+
<plugin>
46+
<groupId>org.springframework.boot</groupId>
47+
<artifactId>spring-boot-maven-plugin</artifactId>
48+
</plugin>
49+
</plugins>
50+
</build>
51+
52+
53+
<repositories>
54+
<repository>
55+
<id>spring-snapshots</id>
56+
<name>Spring Snapshots</name>
57+
<url>https://repo.spring.io/libs-snapshot</url>
58+
<snapshots>
59+
<enabled>true</enabled>
60+
</snapshots>
61+
</repository>
62+
</repositories>
63+
64+
</project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package demo.springboot;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
/**
7+
* Spring Boot 应用启动类
8+
*
9+
* Created by bysocket on 26/09/2017.
10+
*/
11+
@SpringBootApplication
12+
public class QuickStartApplication {
13+
public static void main(String[] args) {
14+
SpringApplication.run(QuickStartApplication.class, args);
15+
}
16+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package demo.springboot.web;
2+
3+
import org.springframework.web.bind.annotation.RequestMapping;
4+
import org.springframework.web.bind.annotation.RequestMethod;
5+
import org.springframework.web.bind.annotation.RestController;
6+
7+
/**
8+
* Spring Boot Hello案例
9+
*
10+
* Created by bysocket on 26/09/2017.
11+
*/
12+
@RestController
13+
public class HelloBookController {
14+
15+
@RequestMapping(value = "/book/hello",method = RequestMethod.GET)
16+
public String sayHello() {
17+
return "Hello,《Spring Boot 2.x 核心技术实战 - 上 基础篇》!";
18+
}
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package demo.springboot.web;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.web.bind.annotation.RequestMapping;
5+
import org.springframework.web.bind.annotation.RequestMethod;
6+
import org.springframework.web.bind.annotation.ResponseBody;
7+
8+
/**
9+
* Spring Boot Hello案例
10+
*
11+
* Created by bysocket on 26/09/2017.
12+
*/
13+
@Controller
14+
public class HelloController {
15+
16+
@RequestMapping(value = "/hello",method = RequestMethod.GET)
17+
@ResponseBody
18+
public String sayHello() {
19+
return "Hello,Spring Boot!";
20+
}
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package demo.springboot;
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 QuickStartApplicationTests {
11+
12+
@Test
13+
public void contextLoads() {
14+
}
15+
16+
}

chapter-2-spring-boot-config/pom.xml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<name>chapter-2-spring-boot-config</name>
6+
<description>《Spring Boot 2.x 核心技术实战 - 上 基础篇》第 2 章《Spring Boot 配置》Demo</description>
7+
8+
<groupId>demo.springboot</groupId>
9+
<artifactId>chapter-2-spring-boot-config</artifactId>
10+
<version>1.0</version>
11+
<packaging>jar</packaging>
12+
13+
<parent>
14+
<groupId>org.springframework.boot</groupId>
15+
<artifactId>spring-boot-starter-parent</artifactId>
16+
<version>2.0.0.BUILD-SNAPSHOT</version>
17+
</parent>
18+
19+
<properties>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
22+
<java.version>1.8</java.version>
23+
</properties>
24+
25+
<dependencies>
26+
27+
<!-- Web 依赖 -->
28+
<dependency>
29+
<groupId>org.springframework.boot</groupId>
30+
<artifactId>spring-boot-starter-web</artifactId>
31+
</dependency>
32+
33+
<!-- 自定义 swagger2 Starter 组件依赖 -->
34+
<dependency>
35+
<groupId>com.spring4all</groupId>
36+
<artifactId>spring-boot-starter-swagger</artifactId>
37+
<version>1.5.1.RELEASE</version>
38+
</dependency>
39+
40+
<!-- 测试依赖 -->
41+
<dependency>
42+
<groupId>org.springframework.boot</groupId>
43+
<artifactId>spring-boot-starter-test</artifactId>
44+
<scope>test</scope>
45+
</dependency>
46+
47+
</dependencies>
48+
49+
<build>
50+
<plugins>
51+
<!-- Spring Boot Maven 插件 -->
52+
<plugin>
53+
<groupId>org.springframework.boot</groupId>
54+
<artifactId>spring-boot-maven-plugin</artifactId>
55+
<version>1.5.1.RELEASE</version>
56+
</plugin>
57+
58+
</plugins>
59+
</build>
60+
61+
62+
<repositories>
63+
<repository>
64+
<id>spring-snapshots</id>
65+
<name>Spring Snapshots</name>
66+
<url>https://repo.spring.io/libs-snapshot</url>
67+
<snapshots>
68+
<enabled>true</enabled>
69+
</snapshots>
70+
</repository>
71+
</repositories>
72+
73+
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package demo.springboot;
2+
3+
import com.spring4all.swagger.EnableSwagger2Doc;
4+
import org.springframework.boot.SpringApplication;
5+
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
7+
/**
8+
* Spring Boot 应用启动类
9+
*
10+
* Created by bysocket on 26/09/2017.
11+
*/
12+
@EnableSwagger2Doc // 开启 Swagger
13+
@SpringBootApplication
14+
public class ConfigApplication {
15+
public static void main(String[] args) {
16+
SpringApplication.run(ConfigApplication.class, args);
17+
}
18+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package demo.springboot.config;
2+
3+
import org.springframework.boot.context.properties.ConfigurationProperties;
4+
import org.springframework.stereotype.Component;
5+
import org.springframework.validation.annotation.Validated;
6+
7+
import javax.validation.constraints.NotEmpty;
8+
import javax.validation.constraints.NotNull;
9+
10+
/**
11+
* 书属性
12+
*
13+
*/
14+
@Component
15+
@ConfigurationProperties(prefix = "demo.book")
16+
@Validated
17+
public class BookComponent {
18+
19+
/**
20+
* 书名
21+
*/
22+
@NotEmpty
23+
private String name;
24+
25+
/**
26+
* 作者
27+
*/
28+
@NotNull
29+
private String writer;
30+
31+
public String getName() {
32+
return name;
33+
}
34+
35+
public void setName(String name) {
36+
this.name = name;
37+
}
38+
39+
public String getWriter() {
40+
return writer;
41+
}
42+
43+
public void setWriter(String writer) {
44+
this.writer = writer;
45+
}
46+
}

0 commit comments

Comments
 (0)