Skip to content

Commit 71560ba

Browse files
committed
重新整理的工程
1 parent 3251a5a commit 71560ba

18 files changed

Lines changed: 600 additions & 0 deletions

File tree

Chapter1/pom.xml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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>demo</artifactId>
8+
<version>1.0.0</version>
9+
<packaging>jar</packaging>
10+
11+
<name>demo</name>
12+
<description>Spring Boot Web 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+
<dependency>
44+
<groupId>org.springframework.boot</groupId>
45+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
46+
</dependency>
47+
48+
</dependencies>
49+
50+
<build>
51+
<plugins>
52+
<plugin>
53+
<groupId>org.springframework.boot</groupId>
54+
<artifactId>spring-boot-maven-plugin</artifactId>
55+
<configuration>
56+
<fork>true</fork>
57+
</configuration>
58+
</plugin>
59+
</plugins>
60+
</build>
61+
62+
63+
</project>
Lines changed: 22 additions & 0 deletions
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+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.didispace.web;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.ui.ModelMap;
5+
import org.springframework.web.bind.annotation.RequestMapping;
6+
import org.springframework.web.bind.annotation.RestController;
7+
8+
/**
9+
*
10+
* @author 程序猿DD
11+
* @version 1.0.0
12+
* @blog http://blog.didispace.com
13+
*
14+
*/
15+
@Controller
16+
public class HelloController {
17+
18+
@RequestMapping("/hello")
19+
public String hello() {
20+
return "Hello World";
21+
}
22+
23+
@RequestMapping("/")
24+
public String index(ModelMap map) {
25+
map.addAttribute("host", "http://blog.didispace.com");
26+
return "index";
27+
}
28+
29+
}

Chapter1/src/main/resources/application.properties

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head lang="en">
4+
<meta charset="UTF-8" />
5+
<title></title>
6+
</head>
7+
<body>
8+
<h1 th:text="${host}">Hello World</h1>
9+
</body>
10+
</html>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
/**
22+
*
23+
* @author 程序猿DD
24+
* @version 1.0.0
25+
* @blog http://blog.didispace.com
26+
*
27+
*/
28+
@RunWith(SpringJUnit4ClassRunner.class)
29+
@SpringApplicationConfiguration(classes = MockServletContext.class)
30+
@WebAppConfiguration
31+
public class ApplicationTests {
32+
33+
private MockMvc mvc;
34+
35+
@Before
36+
public void setUp() throws Exception {
37+
mvc = MockMvcBuilders.standaloneSetup(
38+
new HelloController()).build();
39+
}
40+
41+
@Test
42+
public void getHello() throws Exception {
43+
mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON))
44+
.andExpect(status().isOk())
45+
.andExpect(content().string(equalTo("Hello World")));
46+
}
47+
48+
}

Chapter3-1-1/pom.xml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
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+
56+
</project>
Lines changed: 22 additions & 0 deletions
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+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.didispace.domain;
2+
3+
4+
5+
/**
6+
*
7+
* @author 程序猿DD
8+
* @version 1.0.0
9+
* @blog http://blog.didispace.com
10+
*
11+
*/
12+
public class User {
13+
14+
private Long id;
15+
private String name;
16+
private Integer age;
17+
18+
public Long getId() {
19+
return id;
20+
}
21+
22+
public void setId(Long id) {
23+
this.id = id;
24+
}
25+
26+
public String getName() {
27+
return name;
28+
}
29+
30+
public void setName(String name) {
31+
this.name = name;
32+
}
33+
34+
public Integer getAge() {
35+
return age;
36+
}
37+
38+
public void setAge(Integer age) {
39+
this.age = age;
40+
}
41+
}
Lines changed: 21 additions & 0 deletions
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+
}

0 commit comments

Comments
 (0)