Giter Site home page Giter Site logo

atishay007 / spring-boot-with-restful-web-services Goto Github PK

View Code? Open in Web Editor NEW
3.0 0.0 0.0 128 KB

Spring Boot with RESTful Web Services.

Java 100.00%
spring-boot h2-database h2-console h2-embedded-database restful-api maven internationalization rest-versioning yaml-configuration java-8 spring-security annotations yml pom tomcat hal-browser requestbody

spring-boot-with-restful-web-services's Introduction

Spring Boot Project.

A small project using Spring Boot which provides operations on User.

It provides following functionalities:

  1. Internalization(Supports US and French- Created 2 properties file{messages_fr.properties, messages.properties})
  2. Basic Spring Authentication (Dependency commented in POM).
  3. Rest API versioning using v1(custom), headers versioning, params versioning.
  4. It uses H2 (In-memory database,which uses data.sql file to create new users), to open H2 UI console http://localhost:9001/h2-console : Use this URL Make sure: jdbc:url in UI is referring to : jdbc:h2:mem:testdb
  5. It uses HATEOAS to create links of other URI.
  6. It uses Spring ResponseEntityExceptionHandler class to provide custom Exception Handling.
  7. It uses javax.validation.Valid annotations to validate the RequestBody coming in POST method.
  8. It uses Swagger to document Rest API (http://localhost:9000/swagger-ui.html) Port can be change, please check application.properties: Change the port where your tomcat is listening.
  9. It Provides response in Json/xml format and accepts the requestBody in both format, to accept/showing responses in XML we have used com.fasterxml.jackson.dataformat dependency.
  10. It uses filtering feature using jackson annotations(It means which fields does user wants to see).
  11. It creates executable jar with the help of dependency in pom(Project Object Model) spring-boot-maven-plugin.
  12. It uses externalizable configuration by using "custom_configuration.properties". Currently supports ".properties file" but the same functinality can be done for yaml or yml(yet another markup language) files.
  13. This app is using Spring Rest WebServices.
  14. Using DevTools to reload the changes without manually restarting the application.
  15. Spring Security Basic In-Memory authentication.
  16. Included dependency for HAL Browser(JSON Hypertext Application Language, or HAL) URL: To open HAL browser with actuator: http://localhost:9008/browser/index.html#/actuator

To open only HAL Browser http://localhost:9008/browser/index.html#

To open any rest url with HAL Browser http://localhost:9008/browser/index.html#/users

Important

  1. Added: How to do external configuration for yml/yaml file (not application.yml) and injecting values using Spring Environment and @Value annotation.
  2. Removed: External configuration for other properties file as it was very easy and there example are available on internet.

Execution:

  1. To run the above app, use below command from cmd prompt. mvn run spring-boot:run
  2. To run the executable jar, open the directory where the jar is created. java -jar spring-microservices-0.0.1-SNAPSHOT.jar

Problems & Solutions:

  1. The Tomcat connector configured to listen on port 9000 failed to start. The port may already be in use or the connector may be misconfigured. Solution: If application fail to start, either change the server port in application.properties or java -jar spring-microservices-0.0.1-SNAPSHOT.jar --server.port=8083 or java -jar -Dserver.port=8083 spring-microservices-0.0.1-SNAPSHOT.jar

  2. If Spring Security is uncommented in POM. User username: user and password: It will be displayed in Console. Use these username and password and set these into Authorization column by selecting Authorization as "Basic"

  3. Implemented Spring Security In-memory basic authentication, please see: BasicAuthenticationHandler.java If sending request from PostMan, use Basic-Auth under Authorization tab and then set the user and password as given in above file

spring-boot-with-restful-web-services's People

Contributors

atishay007 avatar

Stargazers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.