Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

master #1

Merged
merged 59 commits into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
f87d37c
针对2月的答疑提交示例代码
digitalsonic Feb 18, 2019
cae0727
上传课件
digitalsonic Feb 20, 2019
81abacf
上传第3章示例
digitalsonic Feb 20, 2019
74bd414
Delete springbucks.md
digitalsonic Feb 20, 2019
c0fdedb
Merge pull request #3 from digitalsonic/master
geektime-geekbang Feb 20, 2019
d5422a0
Update 第3章-O:R Mapping 实践.pdf
digitalsonic Feb 25, 2019
4d1166f
Merge pull request #4 from digitalsonic/master
geektime-geekbang Feb 25, 2019
dfed477
update pdf filenames
digitalsonic Feb 25, 2019
009bfb6
Merge pull request #5 from digitalsonic/master
geektime-geekbang Feb 26, 2019
669010c
添加第4章讲义
digitalsonic Feb 26, 2019
2e8a31c
Merge pull request #6 from digitalsonic/master
geektime-geekbang Feb 27, 2019
0fb842d
添加第四章示例
digitalsonic Feb 27, 2019
0e524e0
Merge pull request #7 from digitalsonic/master
geektime-geekbang Feb 28, 2019
0e1a4d8
Create 第5章.pdf
digitalsonic Mar 6, 2019
332c4ce
上传第5章代码
digitalsonic Mar 6, 2019
b566c53
Merge pull request #8 from digitalsonic/master
geektime-geekbang Mar 6, 2019
c5c0950
添加第6章示例代码
digitalsonic Mar 12, 2019
f3324f5
Create 第6章.pdf
digitalsonic Mar 12, 2019
50a453a
Merge pull request #9 from digitalsonic/master
geektime-geekbang Mar 12, 2019
5e73d02
Delete 第6章.pdf
digitalsonic Mar 12, 2019
a5de27e
Create 第6章.pdf
digitalsonic Mar 13, 2019
cb68f3a
Merge pull request #10 from digitalsonic/master
geektime-geekbang Mar 13, 2019
fed65b2
Create 答疑 2019-03.pdf
digitalsonic Mar 21, 2019
2a6e741
添加答疑
digitalsonic Mar 21, 2019
be19256
Create 第7章.pdf
digitalsonic Mar 21, 2019
413c1b6
添加第7章
digitalsonic Mar 21, 2019
2af778c
Merge pull request #12 from digitalsonic/master
geektime-geekbang Mar 22, 2019
efc2939
更新PDF
digitalsonic Mar 22, 2019
3db798d
Merge pull request #14 from digitalsonic/master
geektime-geekbang Mar 22, 2019
e113117
Create 第8章.pdf
digitalsonic Mar 24, 2019
39dca7b
上传第8章示例
digitalsonic Mar 24, 2019
2b7044a
Merge pull request #15 from digitalsonic/master
geektime-geekbang Mar 25, 2019
b098bcd
Create 第9章.pdf
digitalsonic Mar 28, 2019
2513c84
添加第9章示例
digitalsonic Mar 28, 2019
dc9aef3
BUGFIX
digitalsonic Apr 1, 2019
b28d3b7
更新PDF
digitalsonic Apr 2, 2019
46dd24f
第十章示例
digitalsonic Apr 3, 2019
fb888d9
Create 第10章.pdf
digitalsonic Apr 3, 2019
0310997
Merge pull request #18 from digitalsonic/master
geektime-geekbang Apr 25, 2019
54f9fd1
Create 第11章.pdf
digitalsonic Apr 25, 2019
2817d00
Merge pull request #19 from digitalsonic/master
geektime-geekbang Apr 26, 2019
7f03bc9
add CH12
digitalsonic Apr 30, 2019
847addf
Create 第12章.pdf
digitalsonic Apr 30, 2019
d060d2d
Merge pull request #21 from digitalsonic/master
geektime-geekbang May 5, 2019
04414b9
添加第13章示例
digitalsonic May 9, 2019
6bbe046
Create 第13章.pdf
digitalsonic May 9, 2019
948c001
Merge pull request #22 from digitalsonic/master
geektime-geekbang May 10, 2019
214e746
添加14章示例
digitalsonic May 15, 2019
e830643
Create 第14章.pdf
digitalsonic May 15, 2019
608fafd
Merge pull request #23 from digitalsonic/master
geektime-geekbang May 16, 2019
c11b5cc
Create 第15章.pdf
digitalsonic May 21, 2019
7118be6
添加15章示例
digitalsonic May 21, 2019
65f6bb6
Create 第16章.pdf
digitalsonic May 21, 2019
6a4ea5d
添加第16章示例
digitalsonic May 21, 2019
d83c83b
Merge pull request #24 from digitalsonic/master
geektime-geekbang May 22, 2019
879eead
Create spring_postman_collection.json
digitalsonic May 25, 2019
ba84222
Merge pull request #26 from digitalsonic/master
geektime-geekbang May 26, 2019
9a434bf
修复提交items的问题
digitalsonic Jul 2, 2019
99c4813
Merge pull request #29 from digitalsonic/master
geektime-geekbang Jul 4, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
29 changes: 29 additions & 0 deletions Chapter 10/command-line-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
HELP.md
/target/
!.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

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

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
/build/

### VS Code ###
.vscode/
48 changes: 48 additions & 0 deletions Chapter 10/command-line-demo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>geektime.spring.hello</groupId>
<artifactId>command-line</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>command-line</name>
<description>Demo project for Spring Boot</description>

<properties>
<java.version>1.8</java.version>
</properties>

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

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</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,17 @@
package geektime.spring.hello;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(2)
@Slf4j
public class BarApplicationRunner implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
log.info("Bar");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package geektime.spring.hello;

import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;

@SpringBootApplication
public class CommandLineApplication {

public static void main(String[] args) {
new SpringApplicationBuilder(CommandLineApplication.class)
.web(WebApplicationType.NONE)
.run(args);
// 根据 application.properties 里的配置来决定 WebApplicationType
// SpringApplication.run(CommandLineApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package geektime.spring.hello;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(3)
@Slf4j
public class ExitApplicationRunner implements ApplicationRunner, ApplicationContextAware {
private ApplicationContext applicationContext;

@Override
public void run(ApplicationArguments args) throws Exception {
int code = SpringApplication.exit(applicationContext);
log.info("Exit with {}.", code);
System.exit(code);
}

@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package geektime.spring.hello;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(1)
@Slf4j
public class FooCommandLineRunner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
log.info("Foo");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package geektime.spring.hello;

import org.springframework.boot.ExitCodeGenerator;
import org.springframework.stereotype.Component;

@Component
public class MyExitCodeGenerator implements ExitCodeGenerator {
@Override
public int getExitCode() {
return 1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
spring.main.web-application-type=none

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package geektime.spring.hello;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class CommandLineApplicationTests {

@Test
public void contextLoads() {
}

}
29 changes: 29 additions & 0 deletions Chapter 10/docker-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
HELP.md
/target/
!.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

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

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
/build/

### VS Code ###
.vscode/
5 changes: 5 additions & 0 deletions Chapter 10/docker-demo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM java:8
EXPOSE 8080
ARG JAR_FILE
ADD target/${JAR_FILE} /waiter-service.jar
ENTRYPOINT ["java", "-jar","/waiter-service.jar"]
109 changes: 109 additions & 0 deletions Chapter 10/docker-demo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>geektime.spring.springbucks</groupId>
<artifactId>waiter-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>waiter-service</name>
<description>Demo project for Spring Boot</description>

<properties>
<java.version>1.8</java.version>
<docker.image.prefix>springbucks</docker.image.prefix>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</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-actuator</artifactId>
</dependency>

<dependency>
<groupId>org.joda</groupId>
<artifactId>joda-money</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.jadira.usertype</groupId>
<artifactId>usertype.core</artifactId>
<version>6.0.1.GA</version>
</dependency>
<!-- 增加Jackson的Hibernate类型支持 -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate5</artifactId>
<version>2.9.8</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</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>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.10</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>${docker.image.prefix}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package geektime.spring.springbucks.waiter;

import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import geektime.spring.springbucks.waiter.controller.PerformanceInteceptor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.TimeZone;

@SpringBootApplication
@EnableJpaRepositories
@EnableCaching
public class WaiterServiceApplication implements WebMvcConfigurer {

public static void main(String[] args) {
SpringApplication.run(WaiterServiceApplication.class, args);
}

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new PerformanceInteceptor())
.addPathPatterns("/coffee/**").addPathPatterns("/order/**");
}

@Bean
public Hibernate5Module hibernate5Module() {
return new Hibernate5Module();
}

@Bean
public Jackson2ObjectMapperBuilderCustomizer jacksonBuilderCustomizer() {
return builder -> {
builder.indentOutput(true);
builder.timeZone(TimeZone.getTimeZone("Asia/Shanghai"));
};
}
}
Loading