Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
50f3d4b
Lesson 11
mercyblitz Aug 9, 2017
c1eea6d
Update README.md
mercyblitz Aug 9, 2017
064dbb7
Add lesson 12
mercyblitz Aug 12, 2017
e4edf7b
Update README.md
mercyblitz Aug 12, 2017
acd6f13
recommit
mercyblitz Aug 12, 2017
5cfff5b
Merge branch 'master' of https://github.com/mercyblitz/segmentfault-l…
mercyblitz Aug 12, 2017
4815b50
add lesson 13
mercyblitz Aug 16, 2017
21ac637
Update README.md
mercyblitz Aug 16, 2017
056d51d
add async servlet for lesson 13
mercyblitz Aug 16, 2017
3d9e6b0
Merge branch 'master' of https://github.com/mercyblitz/segmentfault-l…
mercyblitz Aug 16, 2017
59dfcb7
Add lesson 14
mercyblitz Aug 19, 2017
5e00a7d
Update README.md
mercyblitz Aug 19, 2017
0a50d3a
Add lesson 15
mercyblitz Aug 23, 2017
8bbeb4d
Merge branch 'master' of https://github.com/mercyblitz/segmentfault-l…
mercyblitz Aug 23, 2017
27a0f31
Update README.md
mercyblitz Aug 23, 2017
5d4996e
Add lesson 16
mercyblitz Aug 26, 2017
498640b
Add lesson 16
mercyblitz Aug 26, 2017
e900f12
Update README.md
mercyblitz Aug 26, 2017
b7fbb78
Add lesson 17
mercyblitz Aug 30, 2017
36e501f
Update README.md
mercyblitz Aug 30, 2017
71ba105
Add lesson 18
mercyblitz Sep 9, 2017
527ebfe
Merge branch 'master' of https://github.com/mercyblitz/segmentfault-l…
mercyblitz Sep 9, 2017
da25649
Update README.md
mercyblitz Sep 9, 2017
d5fc407
Add lesson 19
mercyblitz Sep 13, 2017
41486d3
Merge branch 'master' of https://github.com/mercyblitz/segmentfault-l…
mercyblitz Sep 13, 2017
43b86d7
Update README.md
mercyblitz Sep 13, 2017
ece130e
Update README.md
mercyblitz Sep 14, 2017
27b8c02
Update README.md
mercyblitz Sep 14, 2017
872e6b6
Update README.md
mercyblitz Sep 14, 2017
deca0a0
Add lesson 20
mercyblitz Sep 16, 2017
715d650
Merge branch 'master' of https://github.com/mercyblitz/segmentfault-l…
mercyblitz Sep 16, 2017
6cf3470
Update README.md
mercyblitz Sep 16, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 28 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# segmentfault-lession
Segment Fault 在线讲堂 代码工程
Segment Fault 在线讲堂 代码工程
=====================================


## Java 微服务实践 - Spring Boot 系列

# [Java 微服务实战系列课堂](https://segmentfault.com/n/1330000009887617)



## Java 微服务实践 - Spring Boot 系列 ([一键报名,更优惠!](https://segmentfault.com/ls/1650000011063780))



Expand Down Expand Up @@ -87,7 +92,7 @@ Segment Fault 在线讲堂 代码工程



### [第九节 NoSQL](https://segmentfault.com/l/1500000009957330)([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-9))[[问答](https://segmentfault.com/l/1500000009957330/d/1560000010384965)]
### [第九节 NoSQL](https://segmentfault.com/l/1500000009957330)([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-9)) [[问答](https://segmentfault.com/l/1500000009957330/d/1560000010384965)]


* 主要内容:
Expand All @@ -98,7 +103,7 @@ Segment Fault 在线讲堂 代码工程



### [第十节 缓存](https://segmentfault.com/l/1500000009970812)([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-10))[[问答](https://segmentfault.com/l/1500000009970812/d/1560000010509920)]
### [第十节 缓存](https://segmentfault.com/l/1500000009970812)([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-10)) [[问答](https://segmentfault.com/l/1500000009970812/d/1560000010509920)]

* 主要内容

Expand All @@ -109,7 +114,7 @@ Segment Fault 在线讲堂 代码工程



### [第十一节 消息](https://segmentfault.com/l/1500000009971600)
### [第十一节 消息](https://segmentfault.com/l/1500000009971600)([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-11)) [[问答](https://segmentfault.com/l/1500000009971600/d/1560000010580012)]

* 主要内容

Expand All @@ -121,84 +126,84 @@ Segment Fault 在线讲堂 代码工程



### [第十二节 验证](https://segmentfault.com/l/1500000009971716)
### [第十二节 验证](https://segmentfault.com/l/1500000009971716) ([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-12)) [[问答](https://segmentfault.com/l/1500000009971716/d/1560000010630935)]

* 主要内容

* Bean Validation(JSR-303):介绍 Java Bean 验证、核心 API、实现框架 Hibernate Validator
* Bean Validation(JSR-303):介绍 Java Bean 验证、核心 API、实现框架 Hibernate Validator
* Apache commons-validator :介绍最传统 Apache 通用验证器框架,如:长度、邮件等方式
* Spring Validator:介绍 Spring 内置验证器 API、以及自定义实现
* Spring Boot 整合:解读 spring-boot-starter-validation



### [第十三节 WebSocket](https://segmentfault.com/l/1500000009971764)
### [第十三节 WebSocket](https://segmentfault.com/l/1500000009971764) ([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-13)) [[问答](https://segmentfault.com/l/1500000009971764/d/1560000010698298)]

* 主要内容

* WebSocket(JSR-356):简介 WebSocket 协议、解释专业术语(如端点、端和会话等)
* WebSocket(JSR-356):简介 WebSocket 协议、解释专业术语(如端点、端和会话等)
* 生命周期:理解 WebSocket 生命周期(如:开启会话、关闭会话、接受消息等)
* 核心接口:介绍 Java WebSocket 中的核心API(如:@ServerEndpoint、@ClientEndpoint、@OnOpen等)
* 实现容器:当前实现 WebSocket 的主流容器,以及 Tomcat Comet 技术
* Spring Boot 整合:介绍和整合 spring-boot-starter-websocket



### [第十四节 WebService](https://segmentfault.com/l/1500000009978309)
### [第十四节 WebService](https://segmentfault.com/l/1500000009978309) ([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-14)) [[问答](https://segmentfault.com/l/1500000009978309/d/1560000010748545)]

* 主要内容

* Web Services:介绍 WSDL 协议、SOAP协议 以及 XML-PRC
* Web Services:介绍 WSDL 协议、SOAP协议 以及 XML-PRC
* JAX-RS(JSR-224):简介 The Java API for XML-Base Web Servces 2.0 规范
* Web Serices Metadata(JSR-181):介绍 Web Services Metadata 编程模型、注解、Java 映射等
* Spring Boot 整合:介绍和整合 spring-boot-starter-ws



### [第十五节 安全](https://segmentfault.com/l/1500000009978481)
### [第十五节 安全](https://segmentfault.com/l/1500000009978481) ([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-15)) [[问答]](https://segmentfault.com/l/1500000009978481/d/1560000010817910)

* 主要内容

* 客户端安全:介绍 CSRF、CSP、HTTP Struct Transport Security、X-Frames-Options、X-XSS-Protection 等
* 客户端安全:介绍 CSRF、CSP、HTTP Struct Transport Security、X-Frames-Options、X-XSS-Protection 等
* 服务端安全:Authentication 和 Authorization
* Spring Boot 整合:介绍和整合 spring-boot-starter-security



### [第十六节 日志](https://segmentfault.com/l/1500000009978585)
### [第十六节 日志](https://segmentfault.com/l/1500000009978585) ([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-16)) [[问答](https://segmentfault.com/l/1500000009978585/d/1560000010867242)]

* 主要内容

* 日志框架:介绍主流日志框架,以及发展历程 Apache Log4j -> Java Logging -> Logback -> Apache Log4j2
* 日志框架:介绍主流日志框架,以及发展历程 Apache Log4j -> Java Logging -> Logback -> Apache Log4j2
* 统一日志API:介绍统一日志API Apache commons-logging 以及 slf4-api
* 日志设计模式:说明主流日志框架的设计模式
* Spring Boot 整合:集合 spring-boot-starter-logging ,分析Spring Boot 日志系统设计



### [第十七节 监管](https://segmentfault.com/l/1500000009978661)
### [第十七节 监管](https://segmentfault.com/l/1500000009978661) ([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-17)) [[问答](https://segmentfault.com/l/1500000009978661/d/1560000010933454)]

* 主要内容

* JMX(JSR-3):介绍 Java 标准管理规范,着重说明 MBean、MXBean、属性(Attribute)、操作(Operation)等相关概念
* JMX(JSR-3):介绍 Java 标准管理规范,着重说明 MBean、MXBean、属性(Attribute)、操作(Operation)等相关概念
* 核心API:实战的方式深入探讨服务端和客户端核心API的使用,加深理解
* 客户端:讲解主流客户端(JConsole、JVisualVM)以及 HTTP 桥接框架 Jolokia
* Spring Boot 整合:介绍 Spring 对 JMX 的扩展支持,随后再深入探讨自动装配模块



### [第十八节 配置](https://segmentfault.com/l/1500000009978661)
### [第十八节 配置](https://segmentfault.com/l/1500000009978661) ([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-18)) [[问答](https://segmentfault.com/l/1500000009978729/d/1560000011093017)]

* 主要内容

* 外部配置:介绍外部配置文件(Properties以及YAML方式)、命令行,以及占位符的使用
* 外部配置:介绍外部配置文件(Properties以及YAML方式)、命令行,以及占位符的使用
* 配置引用:讲解如何通过编码的方式获取配置项值,以及将该值赋值致Bean的属性上
* Prfoles:说明 Profiles 使用场景,以及在实际生产环节中如何合理的使用
* Environment:通过实战的方式解决和说明Spring Environment接口,以及它与外部配置、Profiles之间的关系



### [第十九节 测试](https://segmentfault.com/l/1500000009978826)
### [第十九节 测试](https://segmentfault.com/l/1500000009978826) ([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-19)) [[问答](https://segmentfault.com/l/1500000009978826/d/1560000011154349)]

* 主要内容

Expand All @@ -209,7 +214,7 @@ Segment Fault 在线讲堂 代码工程



### [第二十节 自定义启动器](https://segmentfault.com/l/1500000009978904)
### [第二十节 自定义启动器](https://segmentfault.com/l/1500000009978904) ([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-20)) [[问答](https://segmentfault.com/l/1500000009978904/d/1560000011202690)]

* 主要内容

Expand All @@ -222,7 +227,7 @@ Segment Fault 在线讲堂 代码工程
## Java 微服务实践 - Spring Cloud 系列


### 持续更新中,请期待
### 10月开播,敬请期待



Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
24 changes: 24 additions & 0 deletions spring-boot/lesson-11/spring-boot-lesson-11/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
target/
!.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
58 changes: 58 additions & 0 deletions spring-boot/lesson-11/spring-boot-lesson-11/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.segmentfault</groupId>
<artifactId>spring-boot-lesson-11</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>spring-boot-lesson-11</name>
<description>Demo project for Spring Boot</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.segmentfault.springbootlesson11;

import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.apache.kafka.common.serialization.StringSerializer;

import java.util.Properties;
import java.util.concurrent.Future;

/**
* 生产者 测试
*
* @author <a href="mailto:[email protected]">Mercy</a>
* @see
* @since 2017.08.09
*/
public class ProducerMain {


public static void main(String[] args) throws Exception {

Properties properties = new Properties();

properties.setProperty("bootstrap.servers", "localhost:9091,localhost:9092,localhost:9093");
properties.put("key.serializer", StringSerializer.class);
properties.put("value.serializer", StringSerializer.class);

KafkaProducer kafkaProducer = new KafkaProducer(properties);

ProducerRecord<String, String> producerRecord = new ProducerRecord<String, String>("sf-2", 0, "message", "大家好");

Future<RecordMetadata> future = kafkaProducer.send(producerRecord);

RecordMetadata recordMetadata = future.get();

System.out.println(recordMetadata);

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.segmentfault.springbootlesson11;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringBootLesson11Application {

public static void main(String[] args) {
SpringApplication.run(SpringBootLesson11Application.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.segmentfault.springbootlesson11.consumer;

import com.segmentfault.springbootlesson11.domain.User;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
* 消费者监听
*
* @author <a href="mailto:[email protected]">Mercy</a>
* @see
* @since 2017.08.09
*/
@Component
public class ConsumerListener {


@KafkaListener(topics = "sf-2")
public void consumer(String message) {

System.out.println(message);

}


@KafkaListener(topics = "sf-users")
public void consumer(User user) {

System.err.println(user);

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.segmentfault.springbootlesson11.controller;

import com.segmentfault.springbootlesson11.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.*;

/**
* Kafka RestController
*
* @author <a href="mailto:[email protected]">Mercy</a>
* @see
* @since 2017.08.09
*/
@RestController
public class KafkaController {

private final KafkaTemplate<String, Object> kafkaTemplate;

@Autowired
public KafkaController(KafkaTemplate kafkaTemplate) {
this.kafkaTemplate = kafkaTemplate;
}


@GetMapping(value = "/message/send")
public String sendMessage(@RequestParam String message) {

kafkaTemplate.send("sf-2", 0, message);

return message;
}

@PostMapping(value = "/user/save")
public User saveUser(@RequestBody User user) {

kafkaTemplate.send("sf-users", 0, user);

return user;

}


}
Loading