Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ingogriebsch/sample-spring-web-simple-restcontroller
This sample shows you how to implement a simple REST controller with Spring Web (and Spring Boot)
https://github.com/ingogriebsch/sample-spring-web-simple-restcontroller
example java sample spring spring-boot spring-web
Last synced: about 1 month ago
JSON representation
This sample shows you how to implement a simple REST controller with Spring Web (and Spring Boot)
- Host: GitHub
- URL: https://github.com/ingogriebsch/sample-spring-web-simple-restcontroller
- Owner: ingogriebsch
- License: apache-2.0
- Created: 2018-10-11T07:47:43.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-06-14T22:44:12.000Z (over 1 year ago)
- Last Synced: 2024-11-13T14:17:23.090Z (3 months ago)
- Topics: example, java, sample, spring, spring-boot, spring-web
- Language: Java
- Homepage:
- Size: 197 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spring Web simple REST controller sample
[](https://github.com/ingogriebsch/sample-spring-web-simple-restcontroller/actions)
[](https://sonarcloud.io/dashboard?id=de.ingogriebsch.samples%3Asample-spring-web-simple-restcontroller)
[](https://sonarcloud.io/dashboard?id=de.ingogriebsch.samples%3Asample-spring-web-simple-restcontroller)
[](https://sonarcloud.io/dashboard?id=de.ingogriebsch.samples%3Asample-spring-web-simple-restcontroller)
[](https://sonarcloud.io/dashboard?id=de.ingogriebsch.samples%3Asample-spring-web-simple-restcontroller)
[](https://sonarcloud.io/dashboard?id=de.ingogriebsch.samples%3Asample-spring-web-simple-restcontroller)
[](http://www.apache.org/licenses/LICENSE-2.0.html)This sample shows how to implement a simple REST controller with Spring Web (and Spring Boot).
## How to build and run
If you want to see the implementation in action, simply follow these steps:* First, make sure that you have Java 8 or later installed and an established Internet connection.
* Then, clone this Git repository an `cd` into the project folder.
* Now invoke `./mvnw spring-boot:run` and wait a moment.After the project is built and the Spring Boot service is running you can hit the following urls to act with the service:
* [http://localhost:8080](http://localhost:8080) allows to access this site.
* [http://localhost:8080/persons](http://localhost:8080/persons) allows to access the person resources available through the service.Have a look into the implementation to understand which endpoints are available in addition.
## Most important annotations and classes
A collection of the most important annotations and classes that are necessary to implement this use case.* [@GetMapping](https://docs.spring.io/spring-framework/docs/5.3.2/javadoc-api/org/springframework/web/bind/annotation/GetMapping.html)
* [@PostMapping](https://docs.spring.io/spring-framework/docs/5.3.2/javadoc-api/org/springframework/web/bind/annotation/PostMapping.html)
* [@DeleteMapping](https://docs.spring.io/spring-framework/docs/5.3.2/javadoc-api/org/springframework/web/bind/annotation/DeleteMapping.html)
* [@RequestMapping](https://docs.spring.io/spring-framework/docs/5.3.2/javadoc-api/org/springframework/web/bind/annotation/RequestMapping.html)
* [@RestController](https://docs.spring.io/spring-framework/docs/5.3.2/javadoc-api/org/springframework/web/bind/annotation/RestController.html)
* [@WebMvcTest](https://docs.spring.io/spring-boot/docs/2.4.1/api/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.html)## Used frameworks
A collection of the mainly used frameworks in this project.
There are more, but they are not that present inside the main use case, therefore they are not listed here.* [Spring Web](https://docs.spring.io/spring-framework/docs/5.3.2/spring-framework-reference/web.html#spring-web)
* [Spring Boot](https://docs.spring.io/spring-boot/docs/2.4.1/reference/htmlsingle/)## Additional guides
The following guides illustrate how to implement this and related use cases.* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
* [Building REST services with Spring](https://spring.io/guides/tutorials/bookmarks/)## License
This code is open source software licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0.html).