Skip to content

Commit 3b9f281

Browse files
authored
readme
readme
1 parent 0717122 commit 3b9f281

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ flylib-boot是针对springboot构建的程序的基础框架,专门用于构
1313
## 使用方法
1414
- Step 1: 进入目录flylib-boot-starter,执行<code>mvn install</code>
1515
- Step 2: 在自己的项目中添加flylib-boot-starter的maven依赖. 并留意自己使用的spring-boot版本,去修改自己的pom.xml文件
16-
```
16+
```xml
1717
<dependency>
1818
<groupId>org.flylib</groupId>
1919
<artifactId>flylib-boot-starter</artifactId>
@@ -22,7 +22,7 @@ flylib-boot是针对springboot构建的程序的基础框架,专门用于构
2222
```
2323
并且要注意这里spring-boot版本是1.5.0.RELEASE. 另外需要添加spring-boot-maven-plugin
2424
实例参考spring-boot-demo项目,它的pom如下:
25-
```
25+
```xml
2626
<?xml version="1.0" encoding="UTF-8"?>
2727
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2828
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -76,7 +76,15 @@ flylib-boot是针对springboot构建的程序的基础框架,专门用于构
7676
```
7777

7878
- Step 3: 在自己的程序中new 一个UserException(自定义的异常类)设置捕获异常
79-
```
79+
```java
80+
/**
81+
* 用户信息的异常
82+
*/
83+
public class UserException extends RuntimeException{
84+
85+
}
86+
87+
8088
@RequestMapping("")
8189
public String index() throws RuntimeException {
8290
UserException userException = new UserException();
@@ -87,7 +95,7 @@ flylib-boot是针对springboot构建的程序的基础框架,专门用于构
8795
```
8896
- Step 4: 运行自己的Spring Boot项目
8997
输出到浏览器的结果
90-
```
98+
```json
9199
{
92100
code:"001",
93101
message:"User not exists",
@@ -97,7 +105,7 @@ flylib-boot是针对springboot构建的程序的基础框架,专门用于构
97105
## 实现原理
98106
利用了@ControllerAdvice@ExceptionHandler
99107
实现代码是
100-
```
108+
```java
101109
package org.flylib.boot.starter.handler;
102110

103111
import org.flylib.boot.starter.exception.CustomRuntimeException;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy