result-spring-boot-starter

REST ful API Result for Spring Boot

License

License

Categories

Categories

Spring Boot Container Microservices
GroupId

GroupId

com.fengwenyi
ArtifactId

ArtifactId

result-spring-boot-starter
Last Version

Last Version

1.0.0.RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

result-spring-boot-starter
REST ful API Result for Spring Boot
Project URL

Project URL

https://projects.spring.io/spring-boot/#/spring-boot-starter-parent/result-spring-boot-starter
Source Code Management

Source Code Management

https://github.com/fengwenyi/result-spring-boot-starter

Download result-spring-boot-starter

How to add to project

<!-- https://jarcasting.com/artifacts/com.fengwenyi/result-spring-boot-starter/ -->
<dependency>
    <groupId>com.fengwenyi</groupId>
    <artifactId>result-spring-boot-starter</artifactId>
    <version>1.0.0.RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/com.fengwenyi/result-spring-boot-starter/
implementation 'com.fengwenyi:result-spring-boot-starter:1.0.0.RELEASE'
// https://jarcasting.com/artifacts/com.fengwenyi/result-spring-boot-starter/
implementation ("com.fengwenyi:result-spring-boot-starter:1.0.0.RELEASE")
'com.fengwenyi:result-spring-boot-starter:jar:1.0.0.RELEASE'
<dependency org="com.fengwenyi" name="result-spring-boot-starter" rev="1.0.0.RELEASE">
  <artifact name="result-spring-boot-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.fengwenyi', module='result-spring-boot-starter', version='1.0.0.RELEASE')
)
libraryDependencies += "com.fengwenyi" % "result-spring-boot-starter" % "1.0.0.RELEASE"
[com.fengwenyi/result-spring-boot-starter "1.0.0.RELEASE"]

Dependencies

compile (2)

Group / Artifact Type Version
org.springframework.boot : spring-boot-configuration-processor Optional jar 2.2.6.RELEASE
com.fengwenyi : api-result jar 2.0.3

provided (5)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter jar 2.2.6.RELEASE
org.springframework : spring-web jar 5.2.5.RELEASE
org.springframework : spring-webmvc jar 5.2.5.RELEASE
javax.servlet : javax.servlet-api jar 4.0.1
com.fasterxml.jackson.core : jackson-databind jar 2.9.8

Project Modules

There are no modules declared in this project.

result-spring-boot-starter

介绍

使用步骤

第一步,添加依赖
<dependency>
    <groupId>com.fengwenyi</groupId>
    <artifactId>result-spring-boot-starter</artifactId>
    <version>1.0.0</version>
</dependency>

第二步,注解@ResponseResult的使用

可以作用在类上,也可以作用在方法上

@RequestMapping("/obj")
@ResponseResult
public User obj() {
    User user = new User();
    user.setS("obj");
    return user;
}

第三步,关于异常处理

全局异常处理

/**
 * Http Request Method Not Supported
 * HttpRequestMethodNotSupportedException
 * @return {@link ErrorResult}
 */
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.class)
public ResultException httpRequestMethodNotSupportException(HttpRequestMethodNotSupportedException e, HttpServletRequest request) {
    return new ResultException("Http Request Method Not Supported");
}

Versions

Version
1.0.0.RELEASE