-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RESTEASY-2500 - add example called
resteasy-spring-rest-annotation
(#…
…50) * RESTEASY-2500 - add example called `resteasy-spring-rest-annotation` * finish working on the example * minor fix * cleanup * fix spring-basic-example
- Loading branch information
Showing
8 changed files
with
129 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# RESTEasy support of Spring REST annotations | ||
|
||
The module shows an example of using RESTEasy to support Spring REST annotations. | ||
|
||
## Building the project | ||
|
||
```bash | ||
$ mvn clean install | ||
``` | ||
|
||
## Running the project and manually testing it | ||
|
||
```bash | ||
$ mvn jetty:run | ||
``` | ||
|
||
Using the `curl` command to access this URL: | ||
|
||
```bash | ||
$ curl http://localhost:8080/spring | ||
``` | ||
|
||
It will return `Spring is coming!` from server side. And the resource class from server side is using Spring REST annotations: | ||
|
||
```java | ||
@RestController | ||
@RequestMapping("/spring") | ||
public class SpringRestAnnotationResource { | ||
|
||
@GetMapping("/") | ||
public String get() { | ||
return "Spring is coming!"; | ||
} | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>testable-examples-pom</artifactId> | ||
<version>4.0.1.Final-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<groupId>org.jboss.resteasy.examples</groupId> | ||
<artifactId>examples-resteasy-spring-rest</artifactId> | ||
<name>Example of Processing Spring Web REST annotations in RESTEasy</name> | ||
<packaging>war</packaging> | ||
<dependencies> | ||
<!-- This dependency is needed by servlet 3.0 container--> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-servlet-initializer</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-core-spi</artifactId> | ||
</dependency> | ||
<!-- This dependency supports Spring REST annotations--> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-spring-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-web</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<finalName>resteasy-spring-example-rest</finalName> | ||
</build> | ||
</project> |
9 changes: 9 additions & 0 deletions
9
resteasy-spring-rest/src/main/java/org/jboss/resteasy/examples/springrest/MyApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.jboss.resteasy.examples.springrest; | ||
|
||
import javax.ws.rs.ApplicationPath; | ||
import javax.ws.rs.core.Application; | ||
|
||
@ApplicationPath("/") | ||
public class MyApplication extends Application { | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...st/src/main/java/org/jboss/resteasy/examples/springrest/SpringRestAnnotationResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.jboss.resteasy.examples.springrest; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/spring") | ||
public class SpringRestAnnotationResource { | ||
|
||
@GetMapping("/") | ||
public String get() { | ||
return "Spring is coming!"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> | ||
<display-name>resteasy-spring-rest</display-name> | ||
|
||
<context-param> | ||
<param-name>resteasy.scanned.resource.classes.with.builder</param-name> | ||
<param-value> | ||
org.jboss.resteasy.spi.metadata.SpringResourceBuilder:org.jboss.resteasy.examples.springrest.SpringRestAnnotationResource | ||
</param-value> | ||
</context-param> | ||
</web-app> |