Skip to content

Commit 61f289b

Browse files
committed
update
1 parent 0468e30 commit 61f289b

File tree

419 files changed

+16730
-0
lines changed

Some content is hidden

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

419 files changed

+16730
-0
lines changed

1.x/Chapter1/pom.xml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
6+
<groupId>com.didispace</groupId>
7+
<artifactId>Chapter1</artifactId>
8+
<version>1.0.0</version>
9+
<packaging>jar</packaging>
10+
11+
<name>Chapter1</name>
12+
<description>The first Spring Boot project</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>1.3.2.RELEASE</version>
18+
<relativePath/> <!-- lookup parent from repository -->
19+
</parent>
20+
21+
<properties>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<java.version>1.8</java.version>
24+
</properties>
25+
26+
<dependencies>
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter</artifactId>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-starter-test</artifactId>
35+
<scope>test</scope>
36+
</dependency>
37+
38+
<dependency>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot-starter-web</artifactId>
41+
</dependency>
42+
43+
</dependencies>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.springframework.boot</groupId>
49+
<artifactId>spring-boot-maven-plugin</artifactId>
50+
</plugin>
51+
</plugins>
52+
</build>
53+
54+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.didispace;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class Chapter1Application {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(Chapter1Application.class, args);
11+
}
12+
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.didispace.web;
2+
3+
import org.springframework.web.bind.annotation.RequestMapping;
4+
import org.springframework.web.bind.annotation.RestController;
5+
6+
@RestController
7+
public class HelloController {
8+
9+
@RequestMapping("/hello")
10+
public String index() {
11+
return "Hello World";
12+
}
13+
14+
}

1.x/Chapter1/src/main/resources/application.properties

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.didispace;
2+
3+
import com.didispace.web.HelloController;
4+
import org.junit.Before;
5+
import org.junit.Test;
6+
import org.junit.runner.RunWith;
7+
import org.springframework.boot.test.SpringApplicationConfiguration;
8+
import org.springframework.http.MediaType;
9+
import org.springframework.mock.web.MockServletContext;
10+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
11+
import org.springframework.test.context.web.WebAppConfiguration;
12+
import org.springframework.test.web.servlet.MockMvc;
13+
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
14+
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
15+
16+
import static org.hamcrest.Matchers.equalTo;
17+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
18+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
19+
20+
21+
@RunWith(SpringJUnit4ClassRunner.class)
22+
@SpringApplicationConfiguration(classes = MockServletContext.class)
23+
@WebAppConfiguration
24+
public class Chapter1ApplicationTests {
25+
26+
private MockMvc mvc;
27+
28+
@Before
29+
public void setUp() throws Exception {
30+
mvc = MockMvcBuilders.standaloneSetup(new HelloController()).build();
31+
}
32+
33+
@Test
34+
public void getHello() throws Exception {
35+
mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON))
36+
.andExpect(status().isOk())
37+
.andExpect(content().string(equalTo("Hello World")));
38+
}
39+
40+
}

1.x/Chapter2-1-1/pom.xml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
6+
<groupId>com.didispace</groupId>
7+
<artifactId>Chapter2-1-1</artifactId>
8+
<version>1.0.0</version>
9+
<packaging>jar</packaging>
10+
11+
<name>Chapter2-1-1</name>
12+
<description></description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>1.3.2.RELEASE</version>
18+
<relativePath/> <!-- lookup parent from repository -->
19+
</parent>
20+
21+
<properties>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<java.version>1.8</java.version>
24+
</properties>
25+
26+
<dependencies>
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter</artifactId>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-starter-test</artifactId>
35+
<scope>test</scope>
36+
</dependency>
37+
38+
<dependency>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot-starter-web</artifactId>
41+
</dependency>
42+
43+
44+
</dependencies>
45+
46+
<build>
47+
<plugins>
48+
<plugin>
49+
<groupId>org.springframework.boot</groupId>
50+
<artifactId>spring-boot-maven-plugin</artifactId>
51+
</plugin>
52+
</plugins>
53+
</build>
54+
55+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.didispace;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
/**
7+
*
8+
* @author 程序猿DD
9+
* @version 1.0.0
10+
* @blog http://blog.didispace.com
11+
*
12+
*/
13+
@SpringBootApplication
14+
public class Application {
15+
16+
public static void main(String[] args) {
17+
18+
SpringApplication.run(Application.class, args);
19+
20+
}
21+
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package com.didispace.service;
2+
3+
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.stereotype.Component;
5+
6+
/**
7+
* @author 程序猿DD
8+
* @version 1.0.0
9+
* @date 16/5/5 下午12:16.
10+
* @blog http://blog.didispace.com
11+
*/
12+
@Component
13+
public class BlogProperties {
14+
15+
@Value("${com.didispace.blog.name}")
16+
private String name;
17+
@Value("${com.didispace.blog.title}")
18+
private String title;
19+
@Value("${com.didispace.blog.desc}")
20+
private String desc;
21+
22+
@Value("${com.didispace.blog.value}")
23+
private String value;
24+
@Value("${com.didispace.blog.number}")
25+
private Integer number;
26+
@Value("${com.didispace.blog.bignumber}")
27+
private Long bignumber;
28+
@Value("${com.didispace.blog.test1}")
29+
private Integer test1;
30+
@Value("${com.didispace.blog.test2}")
31+
private Integer test2;
32+
33+
public String getName() {
34+
return name;
35+
}
36+
37+
public void setName(String name) {
38+
this.name = name;
39+
}
40+
41+
public String getTitle() {
42+
return title;
43+
}
44+
45+
public void setTitle(String title) {
46+
this.title = title;
47+
}
48+
49+
public String getDesc() {
50+
return desc;
51+
}
52+
53+
public void setDesc(String desc) {
54+
this.desc = desc;
55+
}
56+
57+
public String getValue() {
58+
return value;
59+
}
60+
61+
public void setValue(String value) {
62+
this.value = value;
63+
}
64+
65+
public Integer getNumber() {
66+
return number;
67+
}
68+
69+
public void setNumber(Integer number) {
70+
this.number = number;
71+
}
72+
73+
public Long getBignumber() {
74+
return bignumber;
75+
}
76+
77+
public void setBignumber(Long bignumber) {
78+
this.bignumber = bignumber;
79+
}
80+
81+
public Integer getTest1() {
82+
return test1;
83+
}
84+
85+
public void setTest1(Integer test1) {
86+
this.test1 = test1;
87+
}
88+
89+
public Integer getTest2() {
90+
return test2;
91+
}
92+
93+
public void setTest2(Integer test2) {
94+
this.test2 = test2;
95+
}
96+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.didispace.web;
2+
3+
import org.springframework.web.bind.annotation.RequestMapping;
4+
import org.springframework.web.bind.annotation.RestController;
5+
6+
/**
7+
*
8+
* @author 程序猿DD
9+
* @version 1.0.0
10+
* @blog http://blog.didispace.com
11+
*
12+
*/
13+
@RestController
14+
public class HelloController {
15+
16+
@RequestMapping("/hello")
17+
public String index() {
18+
return "Hello World";
19+
}
20+
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# 服务端口
2+
server.port=1111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# 服务端口
2+
server.port=3333
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# 服务端口
2+
server.port=2222
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
com.didispace.blog.name=程序猿DD
2+
com.didispace.blog.title=Spring Boot教程
3+
com.didispace.blog.desc=${com.didispace.blog.name}正在努力写《${com.didispace.blog.title}》
4+
5+
# 随机字符串
6+
com.didispace.blog.value=${random.value}
7+
# 随机int
8+
com.didispace.blog.number=${random.int}
9+
# 随机long
10+
com.didispace.blog.bignumber=${random.long}
11+
# 10以内的随机数
12+
com.didispace.blog.test1=${random.int(10)}
13+
# 10-20的随机数
14+
com.didispace.blog.test2=${random.int[10,20]}
15+
16+
# 多环境配置文件激活属性
17+
spring.profiles.active=dev

0 commit comments

Comments
 (0)