# Java_Exp1 **Repository Path**: simple_one1/java_-exp1 ## Basic Information - **Project Name**: Java_Exp1 - **Description**: No description available - **Primary Language**: Java - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-03-30 - **Last Updated**: 2021-04-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # **实验一 使用Spring Boot构建应用程序** 1. ## **实验目的** 2. 掌握使用IntelliJ IDEA创建Spring Boot应用程序的方法; 3. 了解spring-boot-starter-parent的配置内容; 4. 掌握如何利用Starter扩展Spring Boot应用程序的功能; 5. 掌握如何配置Starter; 6. 掌握如何通过属性文件定制Spring Boot应用程序的初始化参数; 7. 掌握使用Spring Boot编写简单的单元测试; 8. 了解Spring Boot应用程序的Fat Jar文件; 9. 掌握Markdown轻量级标记语言编写README.md文件。 10. ## **实验环境** 11. JDK 1.8或更高版本 12. Maven 3.6+ 13. IntelliJ IDEA 14. ## **实验任务** 15. 通过IntelliJ IDEA的Spring Initializr向导创建Spring Boot项目; 1. 添加两个功能模块:spring MVC、lombok; ![image-20210402182416995](https://gitee.com/simple_one1/pic/raw/master/image-20210402182416995.png) 1. 添加阿里云镜像仓库作为项目maven仓库;![Snipaste_2021-03-30_08-28-04](https://gitee.com/simple_one1/pic/raw/master/Snipaste_2021-03-30_08-28-04.png) 2. 解释项目pom.xml文件中主要标签的意义;![Snipaste_2021-03-30_08-30-03](https://gitee.com/simple_one1/pic/raw/master/Snipaste_2021-03-30_08-30-03.png) 3. 配置jetty或undertow作为Spring Boot应用程序的默认Servlet容器;![Snipaste_2021-03-30_08-32-35](https://gitee.com/simple_one1/pic/raw/master/Snipaste_2021-03-30_08-32-35.png) 4. 配置Gson作为Spring Boot应用程序的默认JSON MessageConverter;(可选)![Snipaste_2021-03-30_08-36-26](https://gitee.com/simple_one1/pic/raw/master/Snipaste_2021-03-30_08-36-26.png) 5. 修改Spring Boot应用程序启动时的Banner;![image-20210402183304470](https://gitee.com/simple_one1/pic/raw/master/image-20210402183304470.png) 6. 添加一个简单的Spring Mvc控制器组件,用于测试,如下图:![image-20210402183331079](https://gitee.com/simple_one1/pic/raw/master/image-20210402183331079.png) 7. 使用IntelliJ IDEA的HTTP Client工具测试控制器端口;![Snipaste_2021-03-30_09-32-16](https://gitee.com/simple_one1/pic/raw/master/Snipaste_2021-03-30_09-32-16.png) 8. 在命令行中使用spring官方提供的mave插件 spring-boot 运行Spring Boot应用程序,并把嵌入式Servlet容器的默认端口8080改为9090;![Snipaste_2021-03-30_09-44-11](https://gitee.com/simple_one1/pic/raw/master/Snipaste_2021-03-30_09-44-11.png) 9. 在属性文件中配置Spring Boot应用程序以debug模式运行。![Snipaste_2021-03-30_09-45-40](https://gitee.com/simple_one1/pic/raw/master/Snipaste_2021-03-30_09-45-40.png) 10. 在命令行中编译、打包Spring Boot应用程序。![Snipaste_2021-03-30_09-44-11](E:\Colleage\6\Java\1\Snipaste_2021-03-30_09-44-11.png) 11. 在命令行中使用java命令运行Spring Boot应用程序的Jar文件。![Snipaste_2021-03-30_10-34-47](https://gitee.com/simple_one1/pic/raw/master/Snipaste_2021-03-30_10-34-47.png) 12. 在命令行中使用java命令运行Spring Boot应用程序的Jar文件,带参数改变嵌入式Servlet容器的默认端口8080改为9090。![Snipaste_2021-03-30_10-36-02](https://gitee.com/simple_one1/pic/raw/master/Snipaste_2021-03-30_10-36-02.png) ## **实验要求** 1. 实验项目push到码云的公开仓库,并把仓库网址登记在在线文档; 2. 从码云仓库下载项目的ZIP文件,并交由班长汇总; 3. 撰写实验报告,完成各个实验任务。各实验任务中的附图,是老师的演示代码,同学们应该模仿演示代码改为自己的代码。实验报告中必须完整描述各实验任务实现过程并附截图。 4. [网络空间安全学院实验报告模板(2019试行)](https://css.dgut.edu.cn/article?262=) 5. [实验一项目仓库登记表](https://docs.qq.com/sheet/DUkRDcGF6Y01BY2pv?c=T7A0A0) 6. 严禁抄袭。如果不想项目仓库给别人看到,可以设置为私有仓库,并把老师的码云账号([dgsai@vip.qq.com](dgsai@vip.qq.com))加入到仓库开发者以便老师检查。