Skip to content

Commit dfbc044

Browse files
committed
MethodArgumentResolver example
1 parent 71d2a32 commit dfbc044

File tree

14 files changed

+516
-0
lines changed

14 files changed

+516
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
HELP.md
2+
.gradle
3+
build/
4+
!gradle/wrapper/gradle-wrapper.jar
5+
!**/src/main/**
6+
!**/src/test/**
7+
8+
### STS ###
9+
.apt_generated
10+
.classpath
11+
.factorypath
12+
.project
13+
.settings
14+
.springBeans
15+
.sts4-cache
16+
17+
### IntelliJ IDEA ###
18+
.idea
19+
*.iws
20+
*.iml
21+
*.ipr
22+
out/
23+
24+
### NetBeans ###
25+
/nbproject/private/
26+
/nbbuild/
27+
/dist/
28+
/nbdist/
29+
/.nb-gradle/
30+
31+
### VS Code ###
32+
.vscode/
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
plugins {
2+
id 'org.springframework.boot' version '2.2.5.RELEASE'
3+
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
4+
id 'java'
5+
}
6+
7+
group = 'io.reflectoring'
8+
version = '0.0.1-SNAPSHOT'
9+
sourceCompatibility = '11'
10+
11+
repositories {
12+
mavenCentral()
13+
}
14+
15+
dependencies {
16+
implementation 'org.springframework.boot:spring-boot-starter'
17+
implementation 'org.springframework.boot:spring-boot-starter-web'
18+
testImplementation('org.springframework.boot:spring-boot-starter-test') {
19+
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
20+
}
21+
22+
compileOnly 'org.projectlombok:lombok'
23+
annotationProcessor 'org.projectlombok:lombok'
24+
}
25+
26+
test {
27+
useJUnitPlatform()
28+
}

spring-boot/argumentresolver/gradlew

Lines changed: 172 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spring-boot/argumentresolver/gradlew.bat

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'argumentresolver'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package io.reflectoring.argumentresolver;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class ArgumentresolverApplication {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(ArgumentresolverApplication.class, args);
11+
}
12+
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.reflectoring.argumentresolver;
2+
3+
import org.springframework.http.ResponseEntity;
4+
import org.springframework.web.bind.annotation.ControllerAdvice;
5+
import org.springframework.web.bind.annotation.ExceptionHandler;
6+
import org.springframework.web.client.HttpStatusCodeException;
7+
8+
@ControllerAdvice
9+
class ErrorHandler {
10+
11+
@ExceptionHandler(HttpStatusCodeException.class)
12+
ResponseEntity<?> handleHttpStatusCodeException(HttpStatusCodeException e) {
13+
return ResponseEntity.status(e.getStatusCode()).build();
14+
}
15+
16+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package io.reflectoring.argumentresolver;
2+
3+
import org.springframework.http.HttpStatus;
4+
import org.springframework.web.client.HttpStatusCodeException;
5+
6+
public class NotFoundException extends HttpStatusCodeException {
7+
8+
protected NotFoundException() {
9+
super(HttpStatus.NOT_FOUND);
10+
}
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.reflectoring.argumentresolver;
2+
3+
4+
import lombok.Value;
5+
6+
@Value
7+
public class Repository {
8+
9+
private final Long id;
10+
private final String slug;
11+
12+
}

0 commit comments

Comments
 (0)