An open API service indexing awesome lists of open source software.

https://github.com/daggerok/resteasy-spring-boot-starter-example

Using RESTEasy Spring Boot starter integration. This is not just builtin Jersey integration!
https://github.com/daggerok/resteasy-spring-boot-starter-example

github-action github-action-docker github-actions github-actions-docker resteasy resteasy-spring-boot

Last synced: 28 days ago
JSON representation

Using RESTEasy Spring Boot starter integration. This is not just builtin Jersey integration!

Awesome Lists containing this project

README

          

# resteasy-spring-boot-starter example [![CI](https://github.com/daggerok/resteasy-spring-boot-starter-example/workflows/CI/badge.svg)](https://github.com/daggerok/resteasy-spring-boot-starter-example/actions?query=workflow%3ACI)
Using RESTEasy Spring Boot starter integration. This is not just builtin Jersey integration!

_pom.xml_

```xml

org.jboss.resteasy
resteasy-spring-boot-starter
4.5.1.Final

```

_app_

```java
@SpringBootApplication
public class RESTEasySpringBootApplication {

@Component
@ApplicationPath("/api")
public static class RESTEasyConfig extends Application {

@Component
@Path("/hello")
@Produces(MediaType.APPLICATION_JSON)
public static class RESTEasyResource {

@GET
public Map hello() {
return Map.of("message", "Hello, World!");
}
}
}

public static void main(String[] args) {
SpringApplication.run(RESTEasySpringBootApplication.class, args);
}
}
```

_tests_

```java
@SpringBootTest
class RESTEasySpringBootApplicationTests {

@Autowired
WebTestClient webTestClient;

@Test
void contextLoads() {
webTestClient.get()
.uri("/api/hello")
.exchange()
.expectStatus().isOk()
.expectBody(new ParameterizedTypeReference>() {})
.consumeWith(mapEntityExchangeResult -> {
var map = mapEntityExchangeResult.getResponseBody();
assertThat(map.get("message")).isNotNull()
.isEqualToIgnoringCase("hello, world!");
});

}
}
```

_or simply_

```bash
./mvnw spring-boot:run
http :8080/api/hello
```

## resources

* https://www.youtube.com/watch?v=khzC-VwpFVM

* https://github.com/resteasy/resteasy-spring-boot/blob/master/mds/USAGE.md