# springboot-demo
**Repository Path**: cbbnice/springboot-demo
## Basic Information
- **Project Name**: springboot-demo
- **Description**: No description available
- **Primary Language**: Java
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-03-24
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# 实验一 使用Spring Boot构建应用程序
院(系)名称:网络空间安全学院
专业班级: 17软卓2班
学号: 201741412219
姓名: 崔彬彬
实验题目: 实验一 使用Spring Boot构建应用程序
实验日期:2020/3/25
实验(上机)学时: 2
成绩:
## 一、实验目的
1、 掌握使用IntelliJ IDEA创建Spring Boot应用程序的方法;
2、 了解spring-boot-starter-parent的配置内容;
3、 掌握如何利用Starter扩展Spring Boot应用程序的功能;
4、 掌握如何配置Starter;
5、 掌握如何通过属性文件定制Spring Boot应用程序的初始化参数;
6、 掌握使用Spring Boot编写简单的单元测试;
7、 了解Spring Boot应用程序的Fat Jar文件;
8、 掌握Markdown轻量级标记语言编写README.md文件。
## 二、实验环境
1、 JDK 1.8或更高版本
2、 Maven 3.6+
3、 IntelliJ IDEA
## 三、实验任务
**1、 通过IntelliJ IDEA的Spring Initializr向导创建Spring Boot项目;**


**2、 添加两个功能模块:spring MVC、lombok;**

**3、 添加阿里云镜像仓库作为项目maven仓库;**
```
AliYun-public
public
https://maven.aliyun.com/repository/public
```
**5、 配置jetty或undertow作为Spring Boot应用程序的默认Servlet容器;**
```
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-tomcat
org.springframework.boot
spring-boot-starter-jetty
2.2.5.RELEASE
```

**6、 添加一个简单的Spring Mvc控制器组件,用于测试:**
```
@RestController
@SpringBootApplication
public class SpringbootDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootDemoApplication.class, args);
}
@RequestMapping("/")
public String home() {
return "Hello,Spring Boot!";
}
}
```
**8、 编写一个简单的单完测试。**
```
@SpringBootTest
@AutoConfigureMockMvc
class SpringbootDemoApplicationTests {
@Autowired
private MockMvc mvc;
@Test
void contextLoads() throws Exception{
mvc.perform(MockMvcRequestBuilders.get("/")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect((ResultMatcher) content().string(equalTo("Hello,Sring Boot!")));
}
}
```
**9、 使用IntelliJ IDEA的HTTP Client工具测试控制器端口;**


**10、 在命令行中使用spring-boot插件运行Spring Boot应用程序,并把嵌入式Servlet容器的默认端口8080改为9090;**

**11、 在属性文件中配置Spring Boot应用程序以debug模式运行。**

**12、 在命令行中编译、打包Spring Boot应用程序。**


**13、 在命令行中使用java命令运行Spring Boot应用程序的Jar文件。**

**14、 在命令行中使用java命令运行Spring Boot应用程序的Jar文件,带参数改变嵌入式Servlet容器的默认端口8080改为9090。**
