# springboot-demo001 **Repository Path**: sfa007/springboot-demo001 ## Basic Information - **Project Name**: springboot-demo001 - **Description**: No description available - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-03-30 - **Last Updated**: 2021-08-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### pom.xml属性意义 > > `groupId`, `artifact ` `version`三元素组成一个Jar的坐标。 > > > > parent包含 grouped,artifact,version,继承父pom则子依赖中不用写版本号 > > > > * parent:被继承的父项目的构件标识符 > > * artifactId:项目的全球唯一标识符 > > * groupId:项目的版本 > > * properties:定义属性 > > * resources:资源文件 > > * plugins:插件 > > * dependency:依赖包 > > * dependencies:依赖 ### 添加两个功能模块:spring MVC、lombok; ```xml org.springframework.boot spring-boot-starter-web org.projectlombok lombok true ``` ### 修改默认嵌入式容器 ```xml org.springframework.boot spring-boot-starter-jetty 2.8.6 ``` ### 配置Gson默认 JSON MessageConverter ```xml com.google.code.gson gson 2.8.6 ``` ### 解释项目 pom.xml 文件中主要标签的意义 ### 修改 Spring Boot 应用程序启动时的 Banner > > resource下新建banner.text > > ![](https://sheepnote.oss-cn-shenzhen.aliyuncs.com/20201006/20210330101243.png) ### 自定义一个 CommandLineRunner ![image-20210329013654642](https://sheepnote.oss-cn-shenzhen.aliyuncs.com/20201006/20210330093128.png) ### 自定义单元测试 `出现乱码问题` 由乱码可知为以ISO-8859-1读取UTF-8所导致 ![image-20210329015140865](https://sheepnote.oss-cn-shenzhen.aliyuncs.com/20201006/20210330093131.png) 更改后通过 `@RequestMapping(value = "/",produces = "application/json;charset=UTF-8")` ![image-20210330101224104](https://sheepnote.oss-cn-shenzhen.aliyuncs.com/20201006/20210330101224.png) `等待仔细研究` ![image-20210329020302717](https://sheepnote.oss-cn-shenzhen.aliyuncs.com/20201006/20210330093043.png) ![image-20210330090358376](https://sheepnote.oss-cn-shenzhen.aliyuncs.com/20201006/20210330092824.png) * 使用powershell默认启动springboot项目正常,带JVM参数时启动失败,[Stack Overflow](https://stackoverflow.com/questions/6347985/cannot-run-maven-using-mvn-d-argument-within-microsoft-powershell-but-works)中有关于cmd运行命令正常而powershell报错的提问,由帖子得-D对powershell为有有特殊意义参数, * 改为使用git命令行运行,运行成功 ![image-20210330093211335](https://sheepnote.oss-cn-shenzhen.aliyuncs.com/20201006/20210330093211.png) ![image-20210330093308420](https://sheepnote.oss-cn-shenzhen.aliyuncs.com/20201006/20210330093308.png) ### 运行http脚本测试 ![image-20210330093945888](https://sheepnote.oss-cn-shenzhen.aliyuncs.com/20201006/20210330093946.png) ### 设置debug 配置文件中设置`debug=true` * ` mvn clean package` * `java -jar target/demo-0.0.1-SNAPSHOT.jar --serverport=9080 --debug` ![image-20210330094831439](https://sheepnote.oss-cn-shenzhen.aliyuncs.com/20201006/20210330094831.png) * gitbash出现中文乱码 * ![image-20210330095008444](https://sheepnote.oss-cn-shenzhen.aliyuncs.com/20201006/20210330095008.png) * `方块形式为以UTF-8读取并显示GBK编码,但是已另存文件为UTF-8编码,仍出现此错误,将bash配置改为GBK则显示正常` ![image-20210330101546955](https://sheepnote.oss-cn-shenzhen.aliyuncs.com/20201006/20210330101547.png)