├── README.md
├── spring-rest-retry-recover
├── spring-rest-server
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ └── application.properties
│ │ │ └── java
│ │ │ └── com
│ │ │ └── roytuts
│ │ │ └── springrestserver
│ │ │ ├── ServerApp.java
│ │ │ ├── service
│ │ │ └── EmployeeService.java
│ │ │ ├── repository
│ │ │ └── EmployeeRepository.java
│ │ │ ├── model
│ │ │ └── Employee.java
│ │ │ └── controller
│ │ │ └── EmployeeRestController.java
│ └── pom.xml
├── readme.rst
└── spring-rest-retry
│ ├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── springrestretry
│ │ ├── ClientApp.java
│ │ ├── controller
│ │ └── EmployeeRestController.java
│ │ ├── custom
│ │ └── CustomRetryPolicy.java
│ │ ├── model
│ │ └── Employee.java
│ │ ├── config
│ │ └── AppConfig.java
│ │ └── service
│ │ └── EmployeeService.java
│ └── pom.xml
├── spring-hateoas
├── readme.rst
├── src
│ └── main
│ │ ├── resources
│ │ ├── application.yml
│ │ └── data.sql
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── spring
│ │ └── hateoas
│ │ ├── SpringHateoas.java
│ │ ├── repository
│ │ └── EmployeeRepository.java
│ │ ├── config
│ │ └── SpringConfig.java
│ │ ├── vo
│ │ └── EmployeeVo.java
│ │ ├── entity
│ │ └── Employee.java
│ │ ├── service
│ │ └── EmployeeService.java
│ │ └── rest
│ │ └── controller
│ │ └── EmployeeRestController.java
├── build.gradle
└── pom.xml
├── spring-rest-junit-mvc
├── readme.rst
├── src
│ └── main
│ │ ├── webapp
│ │ └── index.jsp
│ │ └── java
│ │ └── roytuts
│ │ ├── config
│ │ ├── WebMvcConfig.java
│ │ └── MvcWebApplicationInitializer.java
│ │ ├── model
│ │ └── Product.java
│ │ ├── sevice
│ │ └── ProductService.java
│ │ └── rest
│ │ └── SpringRestController.java
└── pom.xml
├── spring-boot-angular-crud-rest-api
├── readme.rst
├── spring-boot-rest.sql
├── src
│ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── roytuts
│ │ │ └── spring
│ │ │ └── boot
│ │ │ └── angular
│ │ │ └── crud
│ │ │ └── rest
│ │ │ └── api
│ │ │ ├── repository
│ │ │ └── WebsiteRepository.java
│ │ │ ├── SpringAngularCrudRestApiApp.java
│ │ │ ├── vo
│ │ │ └── WebsiteVo.java
│ │ │ ├── entity
│ │ │ └── Website.java
│ │ │ ├── converter
│ │ │ └── EntityVoConverter.java
│ │ │ ├── rest
│ │ │ └── controller
│ │ │ │ └── WebsiteRestController.java
│ │ │ └── service
│ │ │ └── WebsiteService.java
│ │ └── resources
│ │ └── application.properties
└── pom.xml
├── spring-boot-swagger
├── readme.rst
├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── spring
│ │ └── boot
│ │ └── swagger
│ │ ├── SpringSwaggerApp.java
│ │ ├── config
│ │ └── SwaggerConfig.java
│ │ └── rest
│ │ └── controller
│ │ └── GreetingController.java
└── pom.xml
├── spring-concurrency-completablefuture
├── spring-concurrency-concurrent-calls
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ └── application.properties
│ │ │ └── java
│ │ │ └── com
│ │ │ └── roytuts
│ │ │ └── java
│ │ │ └── spring
│ │ │ └── concurrency
│ │ │ └── concurrent
│ │ │ └── calls
│ │ │ ├── BeanConfig.java
│ │ │ ├── CustomAsyncExceptionHandler.java
│ │ │ ├── AsyncService.java
│ │ │ ├── AsyncConfig.java
│ │ │ └── ConcurrentRunnerApp.java
│ ├── pom_3.5.4.xml
│ └── pom.xml
├── readme.rst
└── spring-concurrency-service-api
│ ├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── java
│ │ └── spring
│ │ └── concurrency
│ │ └── service
│ │ └── api
│ │ └── ServiceApiApp.java
│ ├── pom_3.5.4.xml
│ └── pom.xml
├── spring-openapi-documentation
├── readme.rst
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── spring
│ │ └── openapi
│ │ └── documentation
│ │ ├── SpringOpenApiDocumentationApp.java
│ │ └── rest
│ │ └── controller
│ │ └── RestApi.java
├── build.gradle
├── api-docs.yaml
├── pom.xml_3.5.4
├── pom.xml_3_2_5
└── pom.xml
├── spring-rest-junit-complete
├── src
│ ├── main
│ │ ├── webapp
│ │ │ └── index.jsp
│ │ └── java
│ │ │ └── roytuts
│ │ │ ├── config
│ │ │ ├── WebMvcConfig.java
│ │ │ └── MvcWebApplicationInitializer.java
│ │ │ ├── model
│ │ │ └── Product.java
│ │ │ ├── sevice
│ │ │ └── ProductService.java
│ │ │ └── rest
│ │ │ └── SpringRestController.java
│ └── test
│ │ └── java
│ │ └── jeejava
│ │ └── rest
│ │ └── SpringRestControllerTest.java
└── readme.rst
├── spring-rest-optional-path-variable
├── readme.rst
├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── spring
│ │ └── rest
│ │ └── optional
│ │ └── path
│ │ └── variable
│ │ ├── App.java
│ │ └── controller
│ │ └── SpringRestController.java
├── build.gradle
└── pom.xml
├── spring-online-visitor-tracker
├── readme.rst
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── spring
│ │ └── online
│ │ └── visitor
│ │ └── tracker
│ │ ├── repository
│ │ └── VisitorRepository.java
│ │ ├── service
│ │ └── VisitorService.java
│ │ ├── OnlineVisitorTracker.java
│ │ ├── config
│ │ ├── AppConfig.java
│ │ └── SecurityConfig.java
│ │ ├── rest
│ │ └── controller
│ │ │ └── GreetingController.java
│ │ ├── logger
│ │ └── VisitorLogger.java
│ │ └── entity
│ │ └── Visitor.java
└── pom.xml
├── spring-rest-file-upload
├── readme.rst
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── spring
│ │ └── rest
│ │ └── file
│ │ └── upload
│ │ ├── App.java
│ │ └── controller
│ │ └── FileUploadRestController.java
├── build.gradle
├── pom.xml
└── pom.xml_3
├── spring-rest-h2-download-file
├── readme.rst
├── src
│ └── main
│ │ ├── resources
│ │ ├── application.yml
│ │ ├── schema.sql
│ │ ├── data.sql
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── spring
│ │ └── rest
│ │ └── download
│ │ └── file
│ │ ├── repository
│ │ └── EmployeeRepository.java
│ │ ├── vo
│ │ └── EmployeeVo.java
│ │ ├── SpringRestH2FileDownloadApp.java
│ │ ├── service
│ │ └── EmployeeService.java
│ │ ├── entity
│ │ └── Employee.java
│ │ └── rest
│ │ └── controller
│ │ └── EmployeeRestController.java
└── pom.xml
├── spring-rest-large-file-download
├── readme.rst
├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── spring
│ │ └── rest
│ │ └── large
│ │ └── file
│ │ └── download
│ │ ├── config
│ │ └── AppConfig.java
│ │ ├── SpringRestLargeFileDownloadApp.java
│ │ ├── dto
│ │ └── Input.java
│ │ └── rest
│ │ └── controller
│ │ └── FileDownloadRestController.java
└── pom.xml
├── spring-web-exception-handling
├── readme.rst
├── src
│ └── main
│ │ ├── resources
│ │ ├── data.sql
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── spring
│ │ └── web
│ │ └── exception
│ │ └── handling
│ │ ├── constants
│ │ └── AppConstants.java
│ │ ├── exception
│ │ ├── DbException.java
│ │ └── AppException.java
│ │ ├── repository
│ │ └── EmployeeRepository.java
│ │ ├── wrapper
│ │ └── ExceptionWrapper.java
│ │ ├── SpringWebExceptionHandlingApp.java
│ │ ├── entity
│ │ └── Employee.java
│ │ ├── rest
│ │ └── controller
│ │ │ └── EmployeeRestController.java
│ │ └── handler
│ │ └── AppExceptionHandler.java
├── build.gradle
└── pom.xml
├── springboot-rest-api-multivaluemap
├── readme.rst
├── springboot-rest-api-multivaluemap
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── com
│ │ │ └── roytuts
│ │ │ └── springboot
│ │ │ └── rest
│ │ │ └── api
│ │ │ └── multivaluedmap
│ │ │ ├── App.java
│ │ │ └── rest
│ │ │ └── controller
│ │ │ └── AppRestController.java
│ └── pom.xml
└── springboot-rest-api-multivaluemap-client
│ ├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── springboot
│ │ └── rest
│ │ └── api
│ │ └── multivaluedmap
│ │ └── client
│ │ ├── config
│ │ └── RestClientConfig.java
│ │ └── App.java
│ └── pom.xml
├── spring-rest-https-certificate
├── readme.rst
├── spring-rest-https-client
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ ├── certificate.jks
│ │ │ └── javaclient.jks
│ │ │ └── java
│ │ │ └── com
│ │ │ └── roytuts
│ │ │ └── spring
│ │ │ └── rest
│ │ │ └── https
│ │ │ ├── enums
│ │ │ └── TemperatureUnit.java
│ │ │ ├── dto
│ │ │ └── Temperature.java
│ │ │ ├── SpringRestHttpsClientApp.java
│ │ │ ├── client
│ │ │ └── TempConverterRestClient.java
│ │ │ └── config
│ │ │ └── RestConfig.java
│ └── build.gradle
└── spring-rest-https-server
│ ├── src
│ └── main
│ │ ├── resources
│ │ ├── certificate.jks
│ │ ├── truststore.jks
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── spring
│ │ └── rest
│ │ └── https
│ │ ├── enums
│ │ └── TemperatureUnit.java
│ │ ├── SpringRestHttpsServerApp.java
│ │ ├── dto
│ │ └── Temperature.java
│ │ └── rest
│ │ └── controller
│ │ └── TempConverterRestController.java
│ └── build.gradle
├── spring-rest-multiple-files-upload
├── readme.rst
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── spring
│ │ └── rest
│ │ └── multiple
│ │ └── files
│ │ └── upload
│ │ ├── SpringRestMultipleFilesUploadApp.java
│ │ └── rest
│ │ └── controller
│ │ └── MultipleFileUploadRestController.java
├── build.gradle
└── pom.xml
├── spring-resttemplate-proxy-timeout
├── readme.rst
├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── spring
│ │ └── resttemplate
│ │ └── proxy
│ │ └── timeout
│ │ ├── SpringRestTemplateProxyTimeoutApp.java
│ │ ├── RestApiController.java
│ │ └── Config.java
└── pom.xml
├── spring-rest-multiple-files-upload-client
├── readme.rst
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── roytuts
│ └── spring
│ └── rest
│ └── multiple
│ └── files
│ └── upload
│ └── client
│ └── FileUploadClient.java
├── spring-rest-return-different-data-format
├── readme.rst
├── settings.gradle
├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── spring
│ │ └── rest
│ │ └── different
│ │ └── data
│ │ └── format
│ │ ├── SpringRestDataFormatsApp.java
│ │ ├── model
│ │ └── Employee.java
│ │ └── rest
│ │ └── controller
│ │ └── SpringRestController.java
├── build.gradle
└── pom.xml
└── spring-rest-file-download
├── readme.rst
├── src
└── main
│ ├── resources
│ └── application.properties
│ └── java
│ └── com
│ └── roytuts
│ ├── repository
│ └── EmployeeRepository.java
│ ├── service
│ └── EmployeeService.java
│ ├── main
│ └── Application.java
│ ├── entity
│ └── Employee.java
│ └── controller
│ └── FileDownloadRestController.java
├── spring-boot-3
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── roytuts
│ │ └── spring
│ │ └── rest
│ │ └── file
│ │ └── download
│ │ ├── repository
│ │ └── EmployeeRepository.java
│ │ ├── App.java
│ │ ├── service
│ │ └── EmployeeService.java
│ │ ├── entity
│ │ └── Employee.java
│ │ └── controller
│ │ └── FileDownloadRestController.java
└── pom.xml
├── build.gradle
├── example.json
├── pom.xml
└── employee.sql
/README.md:
--------------------------------------------------------------------------------
1 | Spring REST API related programs
2 |
--------------------------------------------------------------------------------
/spring-rest-retry-recover/spring-rest-server/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9000
2 |
--------------------------------------------------------------------------------
/spring-hateoas/readme.rst:
--------------------------------------------------------------------------------
1 | You can read tutorial https://roytuts.com/hateoas-driven-rest-api-using-spring-boot/
--------------------------------------------------------------------------------
/spring-rest-junit-mvc/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/spring-restful-webservice-crud-example/
2 |
--------------------------------------------------------------------------------
/spring-rest-junit-mvc/src/main/webapp/index.jsp:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello World!
4 |
5 |
6 |
--------------------------------------------------------------------------------
/spring-rest-retry-recover/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/spring-rest-api-retryable-and-recover/
2 |
--------------------------------------------------------------------------------
/spring-boot-angular-crud-rest-api/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/angular-spring-boot-rest-api-crud-example/
--------------------------------------------------------------------------------
/spring-boot-swagger/readme.rst:
--------------------------------------------------------------------------------
1 | You can go through the tutorial https://roytuts.com/spring-boot-rest-api-documentation-with-swagger-2/
--------------------------------------------------------------------------------
/spring-concurrency-completablefuture/spring-concurrency-concurrent-calls/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8000
--------------------------------------------------------------------------------
/spring-openapi-documentation/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/how-to-document-rest-apis-with-openapi/
2 |
--------------------------------------------------------------------------------
/spring-rest-junit-complete/src/main/webapp/index.jsp:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello World!
4 |
5 |
6 |
--------------------------------------------------------------------------------
/spring-rest-optional-path-variable/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/spring-rest-optional-pathvariable/
2 |
--------------------------------------------------------------------------------
/spring-online-visitor-tracker/readme.rst:
--------------------------------------------------------------------------------
1 | You can go through the tutorial https://roytuts.com/how-to-log-user-activity-using-spring-boot/
--------------------------------------------------------------------------------
/spring-rest-file-upload/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/file-upload-example-using-spring-rest-controller/
2 |
--------------------------------------------------------------------------------
/spring-rest-h2-download-file/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/download-file-using-angular-and-spring-boot/
2 |
--------------------------------------------------------------------------------
/spring-rest-large-file-download/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/download-large-file-using-spring-rest-api/
2 |
--------------------------------------------------------------------------------
/spring-web-exception-handling/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/exception-handling-in-spring-web-application/
2 |
--------------------------------------------------------------------------------
/springboot-rest-api-multivaluemap/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/spring-boot-rest-api-multivaluemap-example/
2 |
--------------------------------------------------------------------------------
/spring-openapi-documentation/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | springdoc.api-docs.path=/api-docs
2 | springdoc.swagger-ui.path=/swagger.html
--------------------------------------------------------------------------------
/spring-rest-https-certificate/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/rest-over-https-with-client-certificate-authentication/
2 |
--------------------------------------------------------------------------------
/spring-rest-multiple-files-upload/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/how-to-upload-multiple-files-using-spring-rest-api/
2 |
--------------------------------------------------------------------------------
/spring-resttemplate-proxy-timeout/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/spring-resttemplate-with-auth-token-proxy-and-timeout/
--------------------------------------------------------------------------------
/spring-rest-multiple-files-upload-client/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/multipart-file-upload-client-using-spring-rest-template/
2 |
--------------------------------------------------------------------------------
/spring-rest-return-different-data-format/readme.rst:
--------------------------------------------------------------------------------
1 | You can read the tutorial https://roytuts.com/how-to-return-different-data-formats-json-xml-from-spring-rest-api/
--------------------------------------------------------------------------------
/spring-concurrency-completablefuture/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/how-to-call-spring-rest-apis-concurrently-using-java-completablefuture/
2 |
--------------------------------------------------------------------------------
/spring-rest-file-upload/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #multipart max size
2 | spring.http.multipart.max-file-size=10MB
3 | spring.http.multipart.max-request-size=10MB
4 |
--------------------------------------------------------------------------------
/spring-rest-multiple-files-upload/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #multipart max size
2 | spring.http.multipart.max-file-size=10MB
3 | spring.http.multipart.max-request-size=10MB
--------------------------------------------------------------------------------
/spring-rest-file-download/readme.rst:
--------------------------------------------------------------------------------
1 | Please follow the tutorial https://roytuts.com/file-download-example-using-spring-rest-controller/
2 |
3 | For spring boot 3 please check the folder spring-boot-3
4 |
--------------------------------------------------------------------------------
/spring-rest-h2-download-file/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | jpa:
3 | show-sql: true
4 | hibernate:
5 | ddl-auto: none
6 | h2:
7 | console:
8 | enabled: true
--------------------------------------------------------------------------------
/spring-rest-junit-complete/readme.rst:
--------------------------------------------------------------------------------
1 | You can read the following tutorials
2 |
3 | https://roytuts.com/junit-testing-spring-rest-services/
4 |
5 | https://roytuts.com/spring-restful-webservice-crud-example/
6 |
--------------------------------------------------------------------------------
/spring-hateoas/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | jpa:
3 | show-sql: true
4 | h2:
5 | console:
6 | enabled: true
7 | jackson:
8 | default-property-inclusion: NON_NULL
--------------------------------------------------------------------------------
/spring-rest-https-certificate/spring-rest-https-client/src/main/resources/certificate.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roytuts/spring-rest/HEAD/spring-rest-https-certificate/spring-rest-https-client/src/main/resources/certificate.jks
--------------------------------------------------------------------------------
/spring-rest-https-certificate/spring-rest-https-client/src/main/resources/javaclient.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roytuts/spring-rest/HEAD/spring-rest-https-certificate/spring-rest-https-client/src/main/resources/javaclient.jks
--------------------------------------------------------------------------------
/spring-rest-https-certificate/spring-rest-https-server/src/main/resources/certificate.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roytuts/spring-rest/HEAD/spring-rest-https-certificate/spring-rest-https-server/src/main/resources/certificate.jks
--------------------------------------------------------------------------------
/spring-rest-https-certificate/spring-rest-https-server/src/main/resources/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roytuts/spring-rest/HEAD/spring-rest-https-certificate/spring-rest-https-server/src/main/resources/truststore.jks
--------------------------------------------------------------------------------
/spring-rest-file-download/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
2 | spring.datasource.url=jdbc:mysql://localhost:3306/roytuts
3 | spring.datasource.username=root
4 | spring.datasource.password=root
--------------------------------------------------------------------------------
/spring-rest-https-certificate/spring-rest-https-client/src/main/java/com/roytuts/spring/rest/https/enums/TemperatureUnit.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.https.enums;
2 |
3 | public enum TemperatureUnit {
4 |
5 | CELSIUS, FAHRENHEIT;
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/spring-rest-https-certificate/spring-rest-https-server/src/main/java/com/roytuts/spring/rest/https/enums/TemperatureUnit.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.https.enums;
2 |
3 | public enum TemperatureUnit {
4 |
5 | CELSIUS, FAHRENHEIT;
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/spring-rest-file-download/spring-boot-3/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
2 | spring.datasource.url=jdbc:mysql://localhost:3306/roytuts
3 | spring.datasource.username=root
4 | spring.datasource.password=root
5 |
--------------------------------------------------------------------------------
/spring-rest-h2-download-file/src/main/resources/schema.sql:
--------------------------------------------------------------------------------
1 | drop table if exists employee;
2 |
3 | create table employee (
4 | id INTEGER generated by default as identity (start with 1) primary key,
5 | name varchar(25) not null,
6 | email_address varchar(50) not null
7 | );
--------------------------------------------------------------------------------
/spring-rest-file-download/src/main/java/com/roytuts/repository/EmployeeRepository.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 |
5 | import com.roytuts.entity.Employee;
6 |
7 | public interface EmployeeRepository extends JpaRepository {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/spring-rest-https-certificate/spring-rest-https-server/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8443
2 | server.ssl.key-store=classpath:certificate.jks
3 | server.ssl.key-store-password=changeit
4 | server.ssl.key-alias=selfsigned
5 | server.ssl.trust-store=classpath:truststore.jks
6 | server.ssl.trust-store-password=changeit
7 | server.ssl.client-auth=need
--------------------------------------------------------------------------------
/spring-hateoas/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | insert into employee(name,email_address)
2 | values('Soumitra','soumitra@email.com');
3 | insert into employee(name,email_address)
4 | values('Liton','liton@email.com');
5 | insert into employee(name,email_address)
6 | values('Suman','suman@email.com');
7 | insert into employee(name,email_address)
8 | values('Debabrata','debabrata@email.com');
--------------------------------------------------------------------------------
/spring-rest-h2-download-file/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | insert into employee(name,email_address)
2 | values('Soumitra','soumitra@email.com');
3 | insert into employee(name,email_address)
4 | values('Liton','liton@email.com');
5 | insert into employee(name,email_address)
6 | values('Suman','suman@email.com');
7 | insert into employee(name,email_address)
8 | values('Debabrata','debabrata@email.com');
--------------------------------------------------------------------------------
/spring-online-visitor-tracker/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.url=jdbc:h2:mem:roytuts
2 | spring.datasource.driverClassName=org.h2.Driver
3 | spring.datasource.username=sa
4 | spring.datasource.password=
5 |
6 | spring.jpa.show-sql = true
7 |
8 | spring.h2.console.enabled = true
9 | spring.h2.console.path=/h2console/
10 |
11 | spring.jpa.hibernate.ddl-auto = create
--------------------------------------------------------------------------------
/spring-web-exception-handling/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | insert into employee(name,email_address)
2 | values('Soumitra','soumitra@email.com');
3 | insert into employee(name,email_address)
4 | values('Liton','liton@email.com');
5 | insert into employee(name,email_address)
6 | values('Suman','suman@email.com');
7 | insert into employee(name,email_address)
8 | values('Debabrata','debabrata@email.com');
--------------------------------------------------------------------------------
/spring-rest-h2-download-file/src/main/java/com/roytuts/spring/rest/download/file/repository/EmployeeRepository.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.download.file.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 |
5 | import com.roytuts.spring.rest.download.file.entity.Employee;
6 |
7 | public interface EmployeeRepository extends JpaRepository {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/spring-web-exception-handling/src/main/java/com/roytuts/spring/web/exception/handling/constants/AppConstants.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.web.exception.handling.constants;
2 |
3 | public final class AppConstants {
4 |
5 | private AppConstants() {
6 | }
7 |
8 | public final static String SUCCESS = "SUCCESS";
9 | public final static String INCORRECT_RESULT_SIZE = "Incorrect result size";
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/spring-boot-angular-crud-rest-api/spring-boot-rest.sql:
--------------------------------------------------------------------------------
1 | CREATE DATABASE IF NOT EXISTS `roytuts`;
2 | USE `roytuts`;
3 |
4 | CREATE TABLE IF NOT EXISTS `website` (
5 | `id` int NOT NULL AUTO_INCREMENT,
6 | `title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
7 | `url` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
8 | PRIMARY KEY (`id`)
9 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--------------------------------------------------------------------------------
/spring-online-visitor-tracker/src/main/java/com/roytuts/spring/online/visitor/tracker/repository/VisitorRepository.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.online.visitor.tracker.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 |
5 | import com.roytuts.spring.online.visitor.tracker.entity.Visitor;
6 |
7 | public interface VisitorRepository extends JpaRepository {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/spring-rest-file-download/spring-boot-3/src/main/java/com/roytuts/spring/rest/file/download/repository/EmployeeRepository.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.file.download.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 |
5 | import com.roytuts.spring.rest.file.download.entity.Employee;
6 |
7 | public interface EmployeeRepository extends JpaRepository {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/spring-rest-file-upload/src/main/java/com/roytuts/spring/rest/file/upload/App.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.file.upload;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class App {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(App.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-boot-angular-crud-rest-api/src/main/java/com/roytuts/spring/boot/angular/crud/rest/api/repository/WebsiteRepository.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.boot.angular.crud.rest.api.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 |
5 | import com.roytuts.spring.boot.angular.crud.rest.api.entity.Website;
6 |
7 | public interface WebsiteRepository extends JpaRepository {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/spring-rest-junit-mvc/src/main/java/roytuts/config/WebMvcConfig.java:
--------------------------------------------------------------------------------
1 | package roytuts.config;
2 |
3 | import org.springframework.context.annotation.ComponentScan;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.web.servlet.config.annotation.EnableWebMvc;
6 |
7 | @Configuration
8 | @EnableWebMvc
9 | @ComponentScan(basePackages = "roytuts")
10 | public class WebMvcConfig {
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/spring-rest-junit-complete/src/main/java/roytuts/config/WebMvcConfig.java:
--------------------------------------------------------------------------------
1 | package roytuts.config;
2 |
3 | import org.springframework.context.annotation.ComponentScan;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.web.servlet.config.annotation.EnableWebMvc;
6 |
7 | @Configuration
8 | @EnableWebMvc
9 | @ComponentScan(basePackages = "roytuts")
10 | public class WebMvcConfig {
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/spring-rest-file-download/spring-boot-3/src/main/java/com/roytuts/spring/rest/file/download/App.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.file.download;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class App {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(App.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-rest-h2-download-file/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
2 | #spring.datasource.driverClassName=org.h2.Driver
3 | #spring.datasource.username=sa
4 | #spring.datasource.password=
5 |
6 | spring.jpa.show-sql=true
7 | spring.h2.console.enabled=true
8 | spring.jpa.hibernate.ddl-auto=none
9 |
10 | #spring.datasource.schema=classpath:schema.sql
11 | #spring.datasource.data=classpath:data.sql
--------------------------------------------------------------------------------
/spring-rest-retry-recover/spring-rest-server/src/main/java/com/roytuts/springrestserver/ServerApp.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.springrestserver;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class ServerApp {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(ServerApp.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-boot-swagger/src/main/java/com/roytuts/spring/boot/swagger/SpringSwaggerApp.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.boot.swagger;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringSwaggerApp {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringSwaggerApp.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-rest-optional-path-variable/src/main/java/com/roytuts/spring/rest/optional/path/variable/App.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.optional.path.variable;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class App {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(App.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-web-exception-handling/src/main/java/com/roytuts/spring/web/exception/handling/exception/DbException.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.web.exception.handling.exception;
2 |
3 | public class DbException extends Exception {
4 |
5 | private static final long serialVersionUID = 1L;
6 |
7 | public DbException(String message) {
8 | super(message);
9 | }
10 |
11 | public DbException(String message, Throwable cause) {
12 | super(message, cause);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/spring-rest-return-different-data-format/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file was generated by the Gradle 'init' task.
3 | *
4 | * The settings file is used to specify which projects to include in your build.
5 | *
6 | * Detailed information about configuring a multi-project build in Gradle can be found
7 | * in the user manual at https://docs.gradle.org/6.5.1/userguide/multi_project_builds.html
8 | */
9 |
10 | rootProject.name = 'spring-rest-return-different-data-format'
11 |
--------------------------------------------------------------------------------
/spring-hateoas/src/main/java/com/roytuts/spring/hateoas/SpringHateoas.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.hateoas;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication(scanBasePackages = "com.roytuts.spring.hateoas")
7 | public class SpringHateoas {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringHateoas.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-hateoas/src/main/java/com/roytuts/spring/hateoas/repository/EmployeeRepository.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.hateoas.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 |
5 | import com.roytuts.spring.hateoas.entity.Employee;
6 |
7 | public interface EmployeeRepository extends JpaRepository {
8 |
9 | Employee findById(int id);
10 |
11 | Employee findByName(String name);
12 |
13 | Employee findByEmail(String email);
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/springboot-rest-api-multivaluemap/springboot-rest-api-multivaluemap/src/main/java/com/roytuts/springboot/rest/api/multivaluedmap/App.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.springboot.rest.api.multivaluedmap;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class App {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(App.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-web-exception-handling/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.url=jdbc:h2:mem:roytuts
2 | spring.datasource.driverClassName=org.h2.Driver
3 | spring.datasource.username=sa
4 | spring.datasource.password=
5 |
6 | spring.jpa.show-sql = true
7 |
8 | spring.h2.console.enabled = true
9 | spring.h2.console.path=/h2console/
10 |
11 | spring.jpa.hibernate.ddl-auto = create
12 |
13 | #insert data from SQL script after table creation
14 | spring.jpa.defer-datasource-initialization=true
15 |
--------------------------------------------------------------------------------
/spring-rest-large-file-download/src/main/java/com/roytuts/spring/rest/large/file/download/config/AppConfig.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.large.file.download.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.web.client.RestTemplate;
6 |
7 | @Configuration
8 | public class AppConfig {
9 |
10 | @Bean
11 | public RestTemplate restTemplate() {
12 | return new RestTemplate();
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/spring-web-exception-handling/src/main/java/com/roytuts/spring/web/exception/handling/repository/EmployeeRepository.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.web.exception.handling.repository;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 |
5 | import com.roytuts.spring.web.exception.handling.entity.Employee;
6 |
7 | public interface EmployeeRepository extends JpaRepository {
8 |
9 | Employee findByName(String name);
10 |
11 | Employee findByEmail(String email);
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-rest-https-certificate/spring-rest-https-server/src/main/java/com/roytuts/spring/rest/https/SpringRestHttpsServerApp.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.https;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringRestHttpsServerApp {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringRestHttpsServerApp.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-hateoas/src/main/java/com/roytuts/spring/hateoas/config/SpringConfig.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.hateoas.config;
2 |
3 | import org.springframework.boot.autoconfigure.domain.EntityScan;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
6 |
7 | @Configuration
8 | @EntityScan("com.roytuts.spring.hateoas.entity")
9 | @EnableJpaRepositories("com.roytuts.spring.hateoas.repository")
10 | public class SpringConfig {
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/spring-boot-angular-crud-rest-api/src/main/java/com/roytuts/spring/boot/angular/crud/rest/api/SpringAngularCrudRestApiApp.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.boot.angular.crud.rest.api;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringAngularCrudRestApiApp {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringAngularCrudRestApiApp.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-rest-large-file-download/src/main/java/com/roytuts/spring/rest/large/file/download/SpringRestLargeFileDownloadApp.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.large.file.download;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringRestLargeFileDownloadApp {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringRestLargeFileDownloadApp.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-rest-retry-recover/spring-rest-retry/src/main/java/com/roytuts/springrestretry/ClientApp.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.springrestretry;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.retry.annotation.EnableRetry;
6 |
7 | @EnableRetry
8 | @SpringBootApplication
9 | public class ClientApp {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(ClientApp.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/spring-openapi-documentation/src/main/java/com/roytuts/spring/openapi/documentation/SpringOpenApiDocumentationApp.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.openapi.documentation;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringOpenApiDocumentationApp {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringOpenApiDocumentationApp.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-rest-return-different-data-format/src/main/java/com/roytuts/spring/rest/different/data/format/SpringRestDataFormatsApp.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.different.data.format;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringRestDataFormatsApp {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringRestDataFormatsApp.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-rest-multiple-files-upload/src/main/java/com/roytuts/spring/rest/multiple/files/upload/SpringRestMultipleFilesUploadApp.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.multiple.files.upload;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringRestMultipleFilesUploadApp {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringRestMultipleFilesUploadApp.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-resttemplate-proxy-timeout/src/main/java/com/roytuts/spring/resttemplate/proxy/timeout/SpringRestTemplateProxyTimeoutApp.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.resttemplate.proxy.timeout;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringRestTemplateProxyTimeoutApp {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringRestTemplateProxyTimeoutApp.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-concurrency-completablefuture/spring-concurrency-concurrent-calls/src/main/java/com/roytuts/java/spring/concurrency/concurrent/calls/BeanConfig.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.java.spring.concurrency.concurrent.calls;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.web.client.RestTemplate;
6 |
7 | @Configuration
8 | public class BeanConfig {
9 |
10 | @Bean
11 | public RestTemplate restTemplate() {
12 | return new RestTemplate();
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/spring-boot-angular-crud-rest-api/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #Spring Datasource
2 | spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
3 | spring.datasource.url=jdbc:mysql://localhost:3306/roytuts
4 | spring.datasource.username=root
5 | spring.datasource.password=root
6 |
7 | #ignore null fields in json
8 | spring.jackson.default-property-inclusion=NON_NULL
9 |
10 | #SQL related
11 | spring.jpa.show-sql = true
12 | spring.jpa.properties.hibernate.format_sql=true
13 | logging.level.org.hibernate.type.descriptor.sql=trace
14 |
15 | spring.jpa.hibernate.ddl-auto = create
--------------------------------------------------------------------------------
/springboot-rest-api-multivaluemap/springboot-rest-api-multivaluemap-client/src/main/java/com/roytuts/springboot/rest/api/multivaluedmap/client/config/RestClientConfig.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.springboot.rest.api.multivaluemap.client.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.web.client.RestTemplate;
6 |
7 | @Configuration
8 | public class RestClientConfig {
9 |
10 | @Bean
11 | public RestTemplate restTemplate() {
12 | return new RestTemplate();
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/spring-rest-file-download/src/main/java/com/roytuts/service/EmployeeService.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.service;
2 |
3 | import java.util.List;
4 |
5 | import javax.annotation.Resource;
6 |
7 | import org.springframework.stereotype.Service;
8 |
9 | import com.roytuts.entity.Employee;
10 | import com.roytuts.repository.EmployeeRepository;
11 |
12 | @Service
13 | public class EmployeeService {
14 |
15 | @Resource
16 | private EmployeeRepository employeeRepository;
17 |
18 | public List getEmployees() {
19 | return employeeRepository.findAll();
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/spring-rest-large-file-download/src/main/java/com/roytuts/spring/rest/large/file/download/dto/Input.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.large.file.download.dto;
2 |
3 | public class Input {
4 |
5 | private String downloadUrl;
6 | private String downloadPath;
7 |
8 | public String getDownloadUrl() {
9 | return downloadUrl;
10 | }
11 |
12 | public void setDownloadUrl(String downloadUrl) {
13 | this.downloadUrl = downloadUrl;
14 | }
15 |
16 | public String getDownloadPath() {
17 | return downloadPath;
18 | }
19 |
20 | public void setDownloadPath(String downloadPath) {
21 | this.downloadPath = downloadPath;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/spring-rest-https-certificate/spring-rest-https-client/src/main/java/com/roytuts/spring/rest/https/dto/Temperature.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.https.dto;
2 |
3 | import com.roytuts.spring.rest.https.enums.TemperatureUnit;
4 |
5 | public class Temperature {
6 |
7 | private double value;
8 | private TemperatureUnit unit;
9 |
10 | public double getValue() {
11 | return value;
12 | }
13 |
14 | public void setValue(double value) {
15 | this.value = value;
16 | }
17 |
18 | public TemperatureUnit getUnit() {
19 | return unit;
20 | }
21 |
22 | public void setUnit(TemperatureUnit unit) {
23 | this.unit = unit;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/spring-rest-https-certificate/spring-rest-https-server/src/main/java/com/roytuts/spring/rest/https/dto/Temperature.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.https.dto;
2 |
3 | import com.roytuts.spring.rest.https.enums.TemperatureUnit;
4 |
5 | public class Temperature {
6 |
7 | private double value;
8 | private TemperatureUnit unit;
9 |
10 | public double getValue() {
11 | return value;
12 | }
13 |
14 | public void setValue(double value) {
15 | this.value = value;
16 | }
17 |
18 | public TemperatureUnit getUnit() {
19 | return unit;
20 | }
21 |
22 | public void setUnit(TemperatureUnit unit) {
23 | this.unit = unit;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/spring-rest-junit-mvc/src/main/java/roytuts/config/MvcWebApplicationInitializer.java:
--------------------------------------------------------------------------------
1 | package roytuts.config;
2 |
3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
4 |
5 | public class MvcWebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
6 |
7 | @Override
8 | protected Class>[] getRootConfigClasses() {
9 | return new Class[] { WebMvcConfig.class };
10 | }
11 |
12 | @Override
13 | protected Class>[] getServletConfigClasses() {
14 | return null;
15 | }
16 |
17 | @Override
18 | protected String[] getServletMappings() {
19 | return new String[] { "/" };
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/spring-online-visitor-tracker/src/main/java/com/roytuts/spring/online/visitor/tracker/service/VisitorService.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.online.visitor.tracker.service;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.stereotype.Service;
5 |
6 | import com.roytuts.spring.online.visitor.tracker.entity.Visitor;
7 | import com.roytuts.spring.online.visitor.tracker.repository.VisitorRepository;
8 |
9 | @Service
10 | public class VisitorService {
11 |
12 | @Autowired
13 | private VisitorRepository repository;
14 |
15 | public Visitor saveVisitorInfo(Visitor visitor) {
16 | return repository.save(visitor);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/spring-rest-junit-complete/src/main/java/roytuts/config/MvcWebApplicationInitializer.java:
--------------------------------------------------------------------------------
1 | package roytuts.config;
2 |
3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
4 |
5 | public class MvcWebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
6 |
7 | @Override
8 | protected Class>[] getRootConfigClasses() {
9 | return new Class[] { WebMvcConfig.class };
10 | }
11 |
12 | @Override
13 | protected Class>[] getServletConfigClasses() {
14 | return null;
15 | }
16 |
17 | @Override
18 | protected String[] getServletMappings() {
19 | return new String[] { "/" };
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/spring-rest-optional-path-variable/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | springBootVersion = '2.1.4.RELEASE'
4 | }
5 | repositories {
6 | mavenLocal()
7 | mavenCentral()
8 | }
9 | dependencies {
10 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
11 | }
12 | }
13 |
14 | apply plugin: 'java'
15 | apply plugin: 'org.springframework.boot'
16 |
17 | sourceCompatibility = 1.8
18 | targetCompatibility = 1.8
19 |
20 | repositories {
21 | mavenLocal()
22 | mavenCentral()
23 | }
24 |
25 | dependencies {
26 | compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
27 | }
--------------------------------------------------------------------------------
/spring-rest-file-download/spring-boot-3/src/main/java/com/roytuts/spring/rest/file/download/service/EmployeeService.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.file.download.service;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.stereotype.Service;
6 |
7 | import com.roytuts.spring.rest.file.download.entity.Employee;
8 | import com.roytuts.spring.rest.file.download.repository.EmployeeRepository;
9 |
10 | import jakarta.annotation.Resource;
11 |
12 | @Service
13 | public class EmployeeService {
14 |
15 | @Resource
16 | private EmployeeRepository employeeRepository;
17 |
18 | public List getEmployees() {
19 | return employeeRepository.findAll();
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/spring-rest-multiple-files-upload/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | springBootVersion = '2.3.2.RELEASE' to '2.4.5'
4 | }
5 |
6 | repositories {
7 | mavenCentral()
8 | }
9 |
10 | dependencies {
11 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
12 | }
13 | }
14 |
15 | plugins {
16 | id 'java-library'
17 | id 'org.springframework.boot' version "${springBootVersion}"
18 | }
19 |
20 | sourceCompatibility = 12
21 | targetCompatibility = 12
22 |
23 | repositories {
24 | mavenCentral()
25 | }
26 |
27 | dependencies {
28 | implementation "org.springframework.boot:spring-boot-starter-web:${springBootVersion}"
29 | }
--------------------------------------------------------------------------------
/spring-rest-h2-download-file/src/main/java/com/roytuts/spring/rest/download/file/vo/EmployeeVo.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.download.file.vo;
2 |
3 | public class EmployeeVo {
4 |
5 | private Integer id;
6 | private String name;
7 | private String email;
8 |
9 | public Integer getId() {
10 | return id;
11 | }
12 |
13 | public void setId(Integer id) {
14 | this.id = id;
15 | }
16 |
17 | public String getName() {
18 | return name;
19 | }
20 |
21 | public void setName(String name) {
22 | this.name = name;
23 | }
24 |
25 | public String getEmail() {
26 | return email;
27 | }
28 |
29 | public void setEmail(String email) {
30 | this.email = email;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/spring-rest-file-upload/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | springBootVersion = '2.2.5.RELEASE' to 2.4.3
4 | }
5 | repositories {
6 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
10 | }
11 | }
12 |
13 | plugins {
14 | id 'java-library'
15 | id 'org.springframework.boot' version "${springBootVersion}"
16 | }
17 |
18 | sourceCompatibility = 12
19 | targetCompatibility = 12
20 |
21 | repositories {
22 | mavenCentral()
23 | }
24 |
25 | dependencies {
26 | implementation("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
27 | }
--------------------------------------------------------------------------------
/spring-boot-angular-crud-rest-api/src/main/java/com/roytuts/spring/boot/angular/crud/rest/api/vo/WebsiteVo.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.boot.angular.crud.rest.api.vo;
2 |
3 | public class WebsiteVo {
4 |
5 | private Integer id;
6 | private String url;
7 | private String title;
8 |
9 | public Integer getId() {
10 | return id;
11 | }
12 |
13 | public void setId(Integer id) {
14 | this.id = id;
15 | }
16 |
17 | public String getUrl() {
18 | return url;
19 | }
20 |
21 | public void setUrl(String url) {
22 | this.url = url;
23 | }
24 |
25 | public String getTitle() {
26 | return title;
27 | }
28 |
29 | public void setTitle(String title) {
30 | this.title = title;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/spring-web-exception-handling/src/main/java/com/roytuts/spring/web/exception/handling/wrapper/ExceptionWrapper.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.web.exception.handling.wrapper;
2 |
3 | public class ExceptionWrapper {
4 |
5 | private String code;
6 | private String message;
7 |
8 | public ExceptionWrapper(String code, String message) {
9 | this.code = code;
10 | this.message = message;
11 | }
12 |
13 | public String getCode() {
14 | return code;
15 | }
16 |
17 | public void setCode(String code) {
18 | this.code = code;
19 | }
20 |
21 | public String getMessage() {
22 | return message;
23 | }
24 |
25 | public void setMessage(String message) {
26 | this.message = message;
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/spring-rest-https-certificate/spring-rest-https-server/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | springBootVersion = '2.2.4.RELEASE'
4 | }
5 | repositories {
6 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
10 | }
11 | }
12 |
13 | plugins {
14 | id 'java-library'
15 | id 'org.springframework.boot' version '2.2.4.RELEASE'
16 | }
17 |
18 | sourceCompatibility = 12
19 | targetCompatibility = 12
20 |
21 | repositories {
22 | mavenCentral()
23 | }
24 |
25 | dependencies {
26 | implementation("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
27 | }
--------------------------------------------------------------------------------
/spring-rest-file-download/src/main/java/com/roytuts/main/Application.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.main;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.boot.autoconfigure.domain.EntityScan;
6 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
7 |
8 | @EntityScan(basePackages = "com.roytuts.entity")
9 | @SpringBootApplication(scanBasePackages = "com.roytuts")
10 | @EnableJpaRepositories(basePackages = "com.roytuts.repository")
11 | public class Application {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(Application.class, args);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/spring-hateoas/src/main/java/com/roytuts/spring/hateoas/vo/EmployeeVo.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.hateoas.vo;
2 |
3 | import org.springframework.hateoas.EntityModel;
4 |
5 | public class EmployeeVo extends EntityModel {
6 |
7 | private Integer empId;
8 | private String name;
9 | private String email;
10 |
11 | public Integer getEmpId() {
12 | return empId;
13 | }
14 |
15 | public void setEmpId(Integer empId) {
16 | this.empId = empId;
17 | }
18 |
19 | public String getName() {
20 | return name;
21 | }
22 |
23 | public void setName(String name) {
24 | this.name = name;
25 | }
26 |
27 | public String getEmail() {
28 | return email;
29 | }
30 |
31 | public void setEmail(String email) {
32 | this.email = email;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/spring-rest-h2-download-file/src/main/java/com/roytuts/spring/rest/download/file/SpringRestH2FileDownloadApp.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.download.file;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.boot.autoconfigure.domain.EntityScan;
6 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
7 |
8 | @SpringBootApplication
9 | @EntityScan("com.roytuts.spring.rest.download.file.entity")
10 | @EnableJpaRepositories("com.roytuts.spring.rest.download.file.repository")
11 | public class SpringRestH2FileDownloadApp {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(SpringRestH2FileDownloadApp.class, args);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/spring-rest-retry-recover/spring-rest-server/src/main/java/com/roytuts/springrestserver/service/EmployeeService.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.springrestserver.service;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 |
8 | import com.roytuts.springrestserver.model.Employee;
9 | import com.roytuts.springrestserver.repository.EmployeeRepository;
10 |
11 | @Service
12 | public class EmployeeService {
13 |
14 | @Autowired
15 | private EmployeeRepository employeeRepository;
16 |
17 | public List getEmployeeList() {
18 | return employeeRepository.getEmployeeList();
19 | }
20 |
21 | public Employee getEmployee() {
22 | return employeeRepository.getEmployeeById();
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/spring-concurrency-completablefuture/spring-concurrency-concurrent-calls/src/main/java/com/roytuts/java/spring/concurrency/concurrent/calls/CustomAsyncExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.java.spring.concurrency.concurrent.calls;
2 |
3 | import java.lang.reflect.Method;
4 |
5 | import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
6 |
7 | public class CustomAsyncExceptionHandler implements AsyncUncaughtExceptionHandler {
8 |
9 | @Override
10 | public void handleUncaughtException(Throwable throwable, Method method, Object... obj) {
11 | System.out.println("Exception message - " + throwable.getMessage());
12 | System.out.println("Method name - " + method.getName());
13 | for (Object param : obj) {
14 | System.out.println("Parameter value - " + param);
15 | }
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/spring-hateoas/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | springBootVersion = '2.4.5'
4 | }
5 | repositories {
6 | mavenLocal()
7 | mavenCentral()
8 | }
9 | dependencies {
10 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
11 | }
12 | }
13 |
14 | apply plugin: 'java'
15 | apply plugin: 'org.springframework.boot'
16 |
17 | sourceCompatibility = 1.8
18 | targetCompatibility = 1.8
19 |
20 | repositories {
21 | mavenLocal()
22 | mavenCentral()
23 | }
24 |
25 | dependencies {
26 | compile("org.springframework.boot:spring-boot-starter-hateoas:${springBootVersion}")
27 | compile("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}")
28 | runtime("com.h2database:h2:1.4.200")
29 | }
--------------------------------------------------------------------------------
/spring-web-exception-handling/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | springBootVersion = '2.1.5.RELEASE'
4 | }
5 | repositories {
6 | mavenLocal()
7 | mavenCentral()
8 | }
9 | dependencies {
10 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
11 | }
12 | }
13 |
14 | apply plugin: 'java'
15 | apply plugin: 'org.springframework.boot'
16 |
17 | sourceCompatibility = 1.8
18 | targetCompatibility = 1.8
19 |
20 | repositories {
21 | mavenLocal()
22 | mavenCentral()
23 | }
24 |
25 | dependencies {
26 | compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
27 | compile("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}")
28 | runtime("com.h2database:h2:1.4.196")
29 | }
--------------------------------------------------------------------------------
/spring-online-visitor-tracker/src/main/java/com/roytuts/spring/online/visitor/tracker/OnlineVisitorTracker.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.online.visitor.tracker;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.boot.autoconfigure.domain.EntityScan;
6 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
7 |
8 | @SpringBootApplication
9 | @EntityScan(basePackages = "com.roytuts.spring.online.visitor.tracker.entity")
10 | @EnableJpaRepositories(basePackages = "com.roytuts.spring.online.visitor.tracker.repository")
11 | public class OnlineVisitorTracker {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(OnlineVisitorTracker.class, args);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/spring-web-exception-handling/src/main/java/com/roytuts/spring/web/exception/handling/SpringWebExceptionHandlingApp.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.web.exception.handling;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.boot.autoconfigure.domain.EntityScan;
6 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
7 |
8 | @EntityScan("com.roytuts.spring.web.exception.handling.entity")
9 | @EnableJpaRepositories("com.roytuts.spring.web.exception.handling.repository")
10 | @SpringBootApplication
11 | public class SpringWebExceptionHandlingApp {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(SpringWebExceptionHandlingApp.class, args);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/spring-online-visitor-tracker/src/main/java/com/roytuts/spring/online/visitor/tracker/config/AppConfig.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.online.visitor.tracker.config;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
7 |
8 | import com.roytuts.spring.online.visitor.tracker.logger.VisitorLogger;
9 |
10 | @Configuration
11 | public class AppConfig implements WebMvcConfigurer {
12 |
13 | @Autowired
14 | private VisitorLogger visitorLogger;
15 |
16 | @Override
17 | public void addInterceptors(InterceptorRegistry registry) {
18 | registry.addInterceptor(visitorLogger);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/spring-openapi-documentation/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | springBootVersion = '2.2.4.RELEASE'
4 | }
5 | repositories {
6 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
10 | }
11 | }
12 |
13 | plugins {
14 | id 'java-library'
15 | id 'org.springframework.boot' version '2.2.4.RELEASE'
16 | }
17 |
18 | sourceCompatibility = 12
19 | targetCompatibility = 12
20 |
21 | repositories {
22 | mavenCentral()
23 | }
24 |
25 | dependencies {
26 | implementation("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
27 | //implementation('org.springdoc:springdoc-openapi-core:1.1.49')
28 | implementation('org.springdoc:springdoc-openapi-ui:1.2.32')
29 | }
--------------------------------------------------------------------------------
/spring-web-exception-handling/src/main/java/com/roytuts/spring/web/exception/handling/exception/AppException.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.web.exception.handling.exception;
2 |
3 | public class AppException extends Exception {
4 |
5 | private static final long serialVersionUID = 1L;
6 |
7 | private String code;
8 |
9 | public AppException(String message) {
10 | super(message);
11 | this.code = null;
12 | }
13 |
14 | public AppException(Throwable cause) {
15 | super(cause);
16 | this.code = null;
17 | }
18 |
19 | public AppException(String message, String code) {
20 | super(message);
21 | this.code = code;
22 | }
23 |
24 | public AppException(String message, Throwable cause) {
25 | super(message, cause);
26 | this.code = null;
27 | }
28 |
29 | public String getCode() {
30 | return code;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/spring-rest-retry-recover/spring-rest-server/src/main/java/com/roytuts/springrestserver/repository/EmployeeRepository.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.springrestserver.repository;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | import org.springframework.stereotype.Repository;
7 |
8 | import com.roytuts.springrestserver.model.Employee;
9 |
10 | @Repository
11 | public class EmployeeRepository {
12 |
13 | public List getEmployeeList() {
14 | List employees = Arrays.asList(new Employee(1, "Smith John", 1000000.00),
15 | new Employee(2, "John Carle", 1200000.00), new Employee(3, "Micheal Vaun", 1020000.00),
16 | new Employee(4, "Jerome K Jerome", 1250000.00));
17 |
18 | return employees;
19 | }
20 |
21 | public Employee getEmployeeById() {
22 | return new Employee(1, "Smith John", 1000000.00);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/spring-rest-https-certificate/spring-rest-https-client/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | springBootVersion = '2.2.4.RELEASE'
4 | }
5 | repositories {
6 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
10 | }
11 | }
12 |
13 | plugins {
14 | id 'java-library'
15 | id 'org.springframework.boot' version '2.2.4.RELEASE'
16 | }
17 |
18 | sourceCompatibility = 12
19 | targetCompatibility = 12
20 |
21 | repositories {
22 | mavenCentral()
23 | }
24 |
25 | dependencies {
26 | implementation("org.springframework.boot:spring-boot-starter-web:${springBootVersion}") {
27 | exclude group:'org.springframework.boot', module:'spring-boot-starter-tomcat'
28 | }
29 |
30 | implementation("org.apache.httpcomponents:httpclient:4.5.11")
31 | }
--------------------------------------------------------------------------------
/spring-concurrency-completablefuture/spring-concurrency-concurrent-calls/src/main/java/com/roytuts/java/spring/concurrency/concurrent/calls/AsyncService.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.java.spring.concurrency.concurrent.calls;
2 |
3 | import java.util.concurrent.CompletableFuture;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.scheduling.annotation.Async;
7 | import org.springframework.stereotype.Service;
8 | import org.springframework.web.client.RestTemplate;
9 |
10 | @Service
11 | public class AsyncService {
12 |
13 | @Autowired
14 | private RestTemplate restTemplate;
15 |
16 | @Async
17 | public CompletableFuture callMsgService() {
18 | final String msgServiceUrl = "http://localhost:8080/msg";
19 |
20 | final String response = restTemplate.getForObject(msgServiceUrl, String.class);
21 |
22 | return CompletableFuture.completedFuture(response);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/spring-rest-https-certificate/spring-rest-https-client/src/main/java/com/roytuts/spring/rest/https/SpringRestHttpsClientApp.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.https;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.boot.CommandLineRunner;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
7 |
8 | import com.roytuts.spring.rest.https.client.TempConverterRestClient;
9 |
10 | @SpringBootApplication
11 | public class SpringRestHttpsClientApp implements CommandLineRunner {
12 |
13 | @Autowired
14 | private TempConverterRestClient tempConverterRestClient;
15 |
16 | public static void main(String[] args) {
17 | SpringApplication.run(SpringRestHttpsClientApp.class, args);
18 | }
19 |
20 | @Override
21 | public void run(String... args) throws Exception {
22 | tempConverterRestClient.temperature();
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/spring-rest-file-download/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | springBootVersion = '2.2.5.RELEASE' to 2.4.3
4 | }
5 | repositories {
6 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
10 | }
11 | }
12 |
13 | plugins {
14 | id 'java-library'
15 | id 'org.springframework.boot' version "${springBootVersion}"
16 | }
17 |
18 | sourceCompatibility = 12
19 | targetCompatibility = 12
20 |
21 | repositories {
22 | mavenCentral()
23 | }
24 |
25 | dependencies {
26 | implementation("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
27 | implementation("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}")
28 | implementation('mysql:mysql-connector-java:8.0.17')//8.0.22
29 | //required only if jdk 9 or higher version is used
30 | runtimeOnly('javax.xml.bind:jaxb-api:2.4.0-b180830.0359')
31 | }
--------------------------------------------------------------------------------
/spring-rest-return-different-data-format/src/main/java/com/roytuts/spring/rest/different/data/format/model/Employee.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.different.data.format.model;
2 |
3 | public class Employee {
4 |
5 | private String name;
6 | private String designation;
7 |
8 | public Employee() {
9 | }
10 |
11 | public Employee(String name, String designation) {
12 | this.name = name;
13 | this.designation = designation;
14 | }
15 |
16 | public String getName() {
17 | return name;
18 | }
19 |
20 | public void setName(String name) {
21 | this.name = name;
22 | }
23 |
24 | public String getDesignation() {
25 | return designation;
26 | }
27 |
28 | public void setDesignation(String designation) {
29 | this.designation = designation;
30 | }
31 |
32 | @Override
33 | public String toString() {
34 | return "Employee [name=" + name + ", designation=" + designation + "]";
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/spring-rest-return-different-data-format/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | springBootVersion = '2.3.5.RELEASE' to 2.4.5
4 | }
5 |
6 | repositories {
7 | mavenCentral()
8 | jcenter()
9 | }
10 |
11 | dependencies {
12 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
13 | }
14 | }
15 |
16 | plugins {
17 | id 'java-library'
18 | //id 'org.springframework.boot' version "${springBootVersion}"
19 | }
20 |
21 | sourceCompatibility = 12
22 | targetCompatibility = 12
23 |
24 | repositories {
25 | mavenCentral()
26 | jcenter()
27 | }
28 |
29 | dependencies {
30 | implementation("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
31 |
32 | //required for JDK 9 or above for XML response
33 | implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.11.3'
34 | implementation 'javax.xml.bind:jaxb-api:2.4.0-b180830.0359'
35 | implementation 'org.glassfish.jaxb:jaxb-runtime:3.0.0-M5'
36 | }
--------------------------------------------------------------------------------
/spring-concurrency-completablefuture/spring-concurrency-service-api/src/main/java/com/roytuts/java/spring/concurrency/service/api/ServiceApiApp.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.java.spring.concurrency.service.api;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.http.HttpStatus;
6 | import org.springframework.http.ResponseEntity;
7 | import org.springframework.web.bind.annotation.GetMapping;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | @RestController
11 | @SpringBootApplication
12 | public class ServiceApiApp {
13 |
14 | public static void main(String[] args) {
15 | SpringApplication.run(ServiceApiApp.class, args);
16 | }
17 |
18 | @GetMapping("/msg")
19 | public ResponseEntity sayHello() {
20 | try {
21 | Thread.sleep(1000);
22 | } catch (InterruptedException e) {
23 | e.printStackTrace();
24 | }
25 | return new ResponseEntity("Hello", HttpStatus.OK);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/spring-rest-retry-recover/spring-rest-server/src/main/java/com/roytuts/springrestserver/model/Employee.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.springrestserver.model;
2 |
3 | public class Employee {
4 |
5 | private Integer id;
6 |
7 | private String employeeName;
8 |
9 | private Double employeeSalary;
10 |
11 | public Employee() {
12 | }
13 |
14 | public Employee(Integer id, String employeeName, Double employeeSalary) {
15 | this.id = id;
16 | this.employeeName = employeeName;
17 | this.employeeSalary = employeeSalary;
18 | }
19 |
20 | public Integer getId() {
21 | return id;
22 | }
23 |
24 | public void setId(Integer id) {
25 | this.id = id;
26 | }
27 |
28 | public String getEmployeeName() {
29 | return employeeName;
30 | }
31 |
32 | public void setEmployeeName(String employeeName) {
33 | this.employeeName = employeeName;
34 | }
35 |
36 | public Double getEmployeeSalary() {
37 | return employeeSalary;
38 | }
39 |
40 | public void setEmployeeSalary(Double employeeSalary) {
41 | this.employeeSalary = employeeSalary;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/spring-rest-h2-download-file/src/main/java/com/roytuts/spring/rest/download/file/service/EmployeeService.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.download.file.service;
2 |
3 | import java.util.List;
4 | import java.util.stream.Collectors;
5 |
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 |
9 | import com.roytuts.spring.rest.download.file.entity.Employee;
10 | import com.roytuts.spring.rest.download.file.repository.EmployeeRepository;
11 | import com.roytuts.spring.rest.download.file.vo.EmployeeVo;
12 |
13 | @Service
14 | public class EmployeeService {
15 |
16 | @Autowired
17 | private EmployeeRepository employeeRepository;
18 |
19 | public List getEmployeeList() {
20 |
21 | List list = employeeRepository.findAll();
22 | return list.stream().map(emp -> {
23 | EmployeeVo vo = new EmployeeVo();
24 | vo.setId(emp.getId());
25 | vo.setName(emp.getName());
26 | vo.setEmail(emp.getEmail());
27 | return vo;
28 | }).collect(Collectors.toList());
29 |
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/spring-boot-angular-crud-rest-api/src/main/java/com/roytuts/spring/boot/angular/crud/rest/api/entity/Website.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.boot.angular.crud.rest.api.entity;
2 |
3 | import javax.persistence.Column;
4 | import javax.persistence.Entity;
5 | import javax.persistence.GeneratedValue;
6 | import javax.persistence.GenerationType;
7 | import javax.persistence.Id;
8 | import javax.persistence.Table;
9 |
10 | @Table
11 | @Entity
12 | public class Website {
13 |
14 | @Id
15 | @GeneratedValue(strategy = GenerationType.IDENTITY)
16 | private Integer id;
17 |
18 | @Column
19 | private String url;
20 |
21 | @Column
22 | private String title;
23 |
24 | public Integer getId() {
25 | return id;
26 | }
27 |
28 | public void setId(Integer id) {
29 | this.id = id;
30 | }
31 |
32 | public String getUrl() {
33 | return url;
34 | }
35 |
36 | public void setUrl(String url) {
37 | this.url = url;
38 | }
39 |
40 | public String getTitle() {
41 | return title;
42 | }
43 |
44 | public void setTitle(String title) {
45 | this.title = title;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/spring-online-visitor-tracker/src/main/java/com/roytuts/spring/online/visitor/tracker/rest/controller/GreetingController.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.online.visitor.tracker.rest.controller;
2 |
3 | import org.springframework.http.HttpStatus;
4 | import org.springframework.http.ResponseEntity;
5 | import org.springframework.web.bind.annotation.GetMapping;
6 | import org.springframework.web.bind.annotation.PathVariable;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | @RestController
10 | public class GreetingController {
11 |
12 | @GetMapping("/")
13 | public ResponseEntity home() {
14 | return new ResponseEntity("Welcome to User Activity Logging", HttpStatus.OK);
15 | }
16 |
17 | @GetMapping("/hello/{name}")
18 | public ResponseEntity greet(@PathVariable String name) {
19 | return new ResponseEntity("Hello, " + name, HttpStatus.OK);
20 | }
21 |
22 | @GetMapping("/login")
23 | public ResponseEntity login() {
24 | return new ResponseEntity("Hello, this is a secured page", HttpStatus.OK);
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/spring-rest-retry-recover/spring-rest-retry/src/main/java/com/roytuts/springrestretry/controller/EmployeeRestController.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.springrestretry.controller;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.http.HttpStatus;
7 | import org.springframework.http.ResponseEntity;
8 | import org.springframework.web.bind.annotation.GetMapping;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | import com.roytuts.springrestretry.model.Employee;
12 | import com.roytuts.springrestretry.service.EmployeeService;
13 |
14 | @RestController
15 | public class EmployeeRestController {
16 |
17 | @Autowired
18 | private EmployeeService employeeService;
19 |
20 | @GetMapping("/employees")
21 | public ResponseEntity> getEmployees() {
22 | List employees = employeeService.getEmployeeList();
23 | //List employees = employeeService.getEmployeeList2();
24 |
25 | return new ResponseEntity>(employees, HttpStatus.OK);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/spring-rest-file-download/example.json:
--------------------------------------------------------------------------------
1 | {
2 | "quiz": {
3 | "sport": {
4 | "q1": {
5 | "question": "Which one is correct team name in NBA?",
6 | "options": [
7 | "New York Bulls",
8 | "Los Angeles Kings",
9 | "Golden State Warriros",
10 | "Huston Rocket"
11 | ],
12 | "answer": "Huston Rocket"
13 | }
14 | },
15 | "maths": {
16 | "q1": {
17 | "question": "5 + 7 = ?",
18 | "options": [
19 | "10",
20 | "11",
21 | "12",
22 | "13"
23 | ],
24 | "answer": "12"
25 | },
26 | "q2": {
27 | "question": "12 - 8 = ?",
28 | "options": [
29 | "1",
30 | "2",
31 | "3",
32 | "4"
33 | ],
34 | "answer": "4"
35 | }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/springboot-rest-api-multivaluemap/springboot-rest-api-multivaluemap/src/main/java/com/roytuts/springboot/rest/api/multivaluedmap/rest/controller/AppRestController.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.springboot.rest.api.multivaluedmap.rest.controller;
2 |
3 | import java.util.stream.Collectors;
4 |
5 | import org.springframework.http.HttpStatus;
6 | import org.springframework.http.ResponseEntity;
7 | import org.springframework.util.MultiValueMap;
8 | import org.springframework.web.bind.annotation.PostMapping;
9 | import org.springframework.web.bind.annotation.RequestBody;
10 | import org.springframework.web.bind.annotation.RestController;
11 |
12 | @RestController
13 | public class AppRestController {
14 |
15 | @PostMapping("/multiValueMap")
16 | public ResponseEntity multiValueMap(@RequestBody MultiValueMap multiValueMap) {
17 | String encoding = multiValueMap.get("Accept-Encoding").stream().map(String::toString)
18 | .collect(Collectors.joining(","));
19 |
20 | String contentType = multiValueMap.get("Content-Type").get(0);
21 |
22 | return new ResponseEntity(encoding + "," + contentType, HttpStatus.OK);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/spring-rest-optional-path-variable/src/main/java/com/roytuts/spring/rest/optional/path/variable/controller/SpringRestController.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.optional.path.variable.controller;
2 |
3 | import java.util.Optional;
4 |
5 | import org.springframework.http.HttpStatus;
6 | import org.springframework.http.ResponseEntity;
7 | import org.springframework.web.bind.annotation.GetMapping;
8 | import org.springframework.web.bind.annotation.PathVariable;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @RestController
12 | public class SpringRestController {
13 |
14 | @GetMapping(value = { "/hi/{name}", "/hi" })
15 | public ResponseEntity getHi(@PathVariable(required = false) String name) {
16 | return new ResponseEntity(
17 | "Hi " + (name == null || name.length() == 0 ? "Anonymous" : name) + ", Good Morning!", HttpStatus.OK);
18 | }
19 |
20 | @GetMapping(value = { "/hello/{name}", "/hello" })
21 | public ResponseEntity getHello(@PathVariable Optional name) {
22 | return new ResponseEntity("Hello " + (name.isPresent() ? name.get() : "Anonymous") + ", Good Morning!",
23 | HttpStatus.OK);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/spring-rest-retry-recover/spring-rest-retry/src/main/java/com/roytuts/springrestretry/custom/CustomRetryPolicy.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.springrestretry.custom;
2 |
3 | import org.springframework.retry.RetryContext;
4 | import org.springframework.retry.RetryPolicy;
5 | import org.springframework.retry.context.RetryContextSupport;
6 |
7 | public class CustomRetryPolicy implements RetryPolicy {
8 |
9 | private static final long serialVersionUID = 1L;
10 |
11 | private int maxAttempts;
12 |
13 | public CustomRetryPolicy(int maxAttempts) {
14 | this.maxAttempts = maxAttempts;
15 | }
16 |
17 | @Override
18 | public boolean canRetry(RetryContext context) {
19 | int attempts = context.getRetryCount();
20 | return attempts < maxAttempts;
21 | }
22 |
23 | @Override
24 | public RetryContext open(RetryContext parent) {
25 | return new RetryContextSupport(parent);
26 | }
27 |
28 | @Override
29 | public void close(RetryContext context) {
30 |
31 | }
32 |
33 | @Override
34 | public void registerThrowable(RetryContext context, Throwable throwable) {
35 | RetryContextSupport retryContext = (RetryContextSupport) context;
36 | retryContext.registerThrowable(throwable);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/spring-concurrency-completablefuture/spring-concurrency-concurrent-calls/src/main/java/com/roytuts/java/spring/concurrency/concurrent/calls/AsyncConfig.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.java.spring.concurrency.concurrent.calls;
2 |
3 | import java.util.concurrent.Executor;
4 |
5 | import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
6 | import org.springframework.context.annotation.Configuration;
7 | import org.springframework.scheduling.annotation.AsyncConfigurer;
8 | import org.springframework.scheduling.annotation.EnableAsync;
9 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
10 |
11 | @EnableAsync
12 | @Configuration
13 | public class AsyncConfig implements AsyncConfigurer {
14 |
15 | @Override
16 | public Executor getAsyncExecutor() {
17 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
18 | //executor.setCorePoolSize(10);
19 | executor.setCorePoolSize(5);
20 | executor.setMaxPoolSize(25);
21 | executor.setQueueCapacity(100);
22 | executor.initialize();
23 | return executor;
24 | }
25 |
26 | @Override
27 | public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
28 | return new CustomAsyncExceptionHandler();
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/spring-rest-h2-download-file/src/main/java/com/roytuts/spring/rest/download/file/entity/Employee.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.download.file.entity;
2 |
3 | import javax.persistence.Column;
4 | import javax.persistence.Entity;
5 | import javax.persistence.GeneratedValue;
6 | import javax.persistence.GenerationType;
7 | import javax.persistence.Id;
8 |
9 | @Entity
10 | public class Employee {
11 |
12 | @Id
13 | @GeneratedValue(strategy = GenerationType.IDENTITY)
14 | private Integer id;
15 |
16 | private String name;
17 |
18 | @Column(name = "email_address")
19 | private String email;
20 |
21 | public Employee() {
22 | }
23 |
24 | public Employee(Integer id, String name, String email) {
25 | this.id = id;
26 | this.name = name;
27 | this.email = email;
28 | }
29 |
30 | public Integer getId() {
31 | return id;
32 | }
33 |
34 | public void setId(Integer id) {
35 | this.id = id;
36 | }
37 |
38 | public String getName() {
39 | return name;
40 | }
41 |
42 | public void setName(String name) {
43 | this.name = name;
44 | }
45 |
46 | public String getEmail() {
47 | return email;
48 | }
49 |
50 | public void setEmail(String email) {
51 | this.email = email;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/spring-hateoas/src/main/java/com/roytuts/spring/hateoas/entity/Employee.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.hateoas.entity;
2 |
3 | import javax.persistence.Column;
4 | import javax.persistence.Entity;
5 | import javax.persistence.GeneratedValue;
6 | import javax.persistence.GenerationType;
7 | import javax.persistence.Id;
8 |
9 | @Entity
10 | public class Employee {
11 |
12 | @Id
13 | @GeneratedValue(strategy = GenerationType.IDENTITY)
14 | @Column(name = "id")
15 | private Integer empId;
16 | private String name;
17 | @Column(name = "email_address")
18 | private String email;
19 |
20 | public Employee() {
21 | }
22 |
23 | public Employee(Integer empId, String name, String email) {
24 | this.empId = empId;
25 | this.name = name;
26 | this.email = email;
27 | }
28 |
29 | public Integer getEmpId() {
30 | return empId;
31 | }
32 |
33 | public void setEmpId(Integer empId) {
34 | this.empId = empId;
35 | }
36 |
37 | public String getName() {
38 | return name;
39 | }
40 |
41 | public void setName(String name) {
42 | this.name = name;
43 | }
44 |
45 | public String getEmail() {
46 | return email;
47 | }
48 |
49 | public void setEmail(String email) {
50 | this.email = email;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/spring-web-exception-handling/src/main/java/com/roytuts/spring/web/exception/handling/entity/Employee.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.web.exception.handling.entity;
2 |
3 | import javax.persistence.Column;
4 | import javax.persistence.Entity;
5 | import javax.persistence.GeneratedValue;
6 | import javax.persistence.GenerationType;
7 | import javax.persistence.Id;
8 |
9 | @Entity
10 | public class Employee {
11 |
12 | @Id
13 | @GeneratedValue(strategy = GenerationType.IDENTITY)
14 | private Integer id;
15 |
16 | private String name;
17 |
18 | @Column(name = "email_address")
19 | private String email;
20 |
21 | public Employee() {
22 | }
23 |
24 | public Employee(Integer id, String name, String email) {
25 | this.id = id;
26 | this.name = name;
27 | this.email = email;
28 | }
29 |
30 | public Integer getId() {
31 | return id;
32 | }
33 |
34 | public void setId(Integer id) {
35 | this.id = id;
36 | }
37 |
38 | public String getName() {
39 | return name;
40 | }
41 |
42 | public void setName(String name) {
43 | this.name = name;
44 | }
45 |
46 | public String getEmail() {
47 | return email;
48 | }
49 |
50 | public void setEmail(String email) {
51 | this.email = email;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/spring-rest-retry-recover/spring-rest-retry/src/main/java/com/roytuts/springrestretry/model/Employee.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.springrestretry.model;
2 |
3 | public class Employee {
4 |
5 | private Integer id;
6 |
7 | private String employeeName;
8 |
9 | private Double employeeSalary;
10 |
11 | public Employee() {
12 | }
13 |
14 | public Employee(Integer id, String employeeName, Double employeeSalary) {
15 | this.id = id;
16 | this.employeeName = employeeName;
17 | this.employeeSalary = employeeSalary;
18 | }
19 |
20 | public Integer getId() {
21 | return id;
22 | }
23 |
24 | public void setId(Integer id) {
25 | this.id = id;
26 | }
27 |
28 | public String getEmployeeName() {
29 | return employeeName;
30 | }
31 |
32 | public void setEmployeeName(String employeeName) {
33 | this.employeeName = employeeName;
34 | }
35 |
36 | public Double getEmployeeSalary() {
37 | return employeeSalary;
38 | }
39 |
40 | public void setEmployeeSalary(Double employeeSalary) {
41 | this.employeeSalary = employeeSalary;
42 | }
43 |
44 | @Override
45 | public String toString() {
46 | return "Employee [id=" + id + ", employeeName=" + employeeName + ", employeeSalary=" + employeeSalary + "]";
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/spring-rest-file-download/src/main/java/com/roytuts/entity/Employee.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | import javax.persistence.Column;
6 | import javax.persistence.Entity;
7 | import javax.persistence.Id;
8 | import javax.persistence.Table;
9 |
10 | @Entity
11 | @Table(name = "employee")
12 | public class Employee implements Serializable {
13 |
14 | private static final long serialVersionUID = 1L;
15 |
16 | @Id
17 | @Column(name = "id")
18 | private Integer empId;
19 |
20 | @Column(name = "first_name")
21 | private String empFirstName;
22 |
23 | @Column(name = "last_name")
24 | private String empLastName;
25 |
26 | public Integer getEmpId() {
27 | return empId;
28 | }
29 |
30 | public void setEmpId(Integer empId) {
31 | this.empId = empId;
32 | }
33 |
34 | public String getEmpFirstName() {
35 | return empFirstName;
36 | }
37 |
38 | public void setEmpFirstName(String empFirstName) {
39 | this.empFirstName = empFirstName;
40 | }
41 |
42 | public String getEmpLastName() {
43 | return empLastName;
44 | }
45 |
46 | public void setEmpLastName(String empLastName) {
47 | this.empLastName = empLastName;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/spring-rest-retry-recover/spring-rest-server/src/main/java/com/roytuts/springrestserver/controller/EmployeeRestController.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.springrestserver.controller;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.http.HttpStatus;
7 | import org.springframework.http.ResponseEntity;
8 | import org.springframework.web.bind.annotation.GetMapping;
9 | import org.springframework.web.bind.annotation.PathVariable;
10 | import org.springframework.web.bind.annotation.RestController;
11 |
12 | import com.roytuts.springrestserver.model.Employee;
13 | import com.roytuts.springrestserver.service.EmployeeService;
14 |
15 | @RestController
16 | public class EmployeeRestController {
17 |
18 | @Autowired
19 | private EmployeeService employeeService;
20 |
21 | @GetMapping("/employees")
22 | public ResponseEntity> getEmployees() {
23 | return new ResponseEntity>(employeeService.getEmployeeList(), HttpStatus.OK);
24 | }
25 |
26 | @GetMapping("/employee/{id}")
27 | public ResponseEntity getEmployee(@PathVariable Integer id) {
28 | return new ResponseEntity(employeeService.getEmployee(), HttpStatus.OK);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/spring-rest-file-download/spring-boot-3/src/main/java/com/roytuts/spring/rest/file/download/entity/Employee.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.file.download.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | import jakarta.persistence.Column;
6 | import jakarta.persistence.Entity;
7 | import jakarta.persistence.Id;
8 | import jakarta.persistence.Table;
9 |
10 | @Entity
11 | @Table(name = "employee")
12 | public class Employee implements Serializable {
13 |
14 | private static final long serialVersionUID = 1L;
15 |
16 | @Id
17 | @Column(name = "id")
18 | private Integer empId;
19 |
20 | @Column(name = "first_name")
21 | private String empFirstName;
22 |
23 | @Column(name = "last_name")
24 | private String empLastName;
25 |
26 | public Integer getEmpId() {
27 | return empId;
28 | }
29 |
30 | public void setEmpId(Integer empId) {
31 | this.empId = empId;
32 | }
33 |
34 | public String getEmpFirstName() {
35 | return empFirstName;
36 | }
37 |
38 | public void setEmpFirstName(String empFirstName) {
39 | this.empFirstName = empFirstName;
40 | }
41 |
42 | public String getEmpLastName() {
43 | return empLastName;
44 | }
45 |
46 | public void setEmpLastName(String empLastName) {
47 | this.empLastName = empLastName;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/spring-concurrency-completablefuture/spring-concurrency-service-api/pom_3.5.4.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.roytuts
7 | spring-concurrency-service-api
8 | 0.0.1-SNAPSHOT
9 |
10 |
11 | UTF-8
12 | 22
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter-parent
18 | 3.5.4
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-web
25 |
26 |
27 |
28 |
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-maven-plugin
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/spring-rest-file-upload/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | 4.0.0
6 |
7 | com.roytuts
8 | spring-rest-file-upload
9 | 0.0.1-SNAPSHOT
10 |
11 |
12 | UTF-8
13 | 12
14 | 12
15 |
16 |
17 |
18 | org.springframework.boot
19 | spring-boot-starter-parent
20 | 2.4.3
21 |
22 |
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-starter-web
27 |
28 |
29 |
30 |
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-maven-plugin
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/spring-concurrency-completablefuture/spring-concurrency-concurrent-calls/pom_3.5.4.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | com.roytuts
6 | spring-concurrency-concurrent-calls
7 | 0.0.1-SNAPSHOT
8 | jar
9 |
10 |
11 | UTF-8
12 | 22
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter-parent
18 | 3.5.4
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-web
25 |
26 |
27 |
28 |
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-maven-plugin
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/spring-rest-file-upload/pom.xml_3:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | spring-rest-file-upload
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | UTF-8
14 | 19
15 | 19
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-parent
21 | 3.1.5
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 |
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-maven-plugin
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/spring-boot-swagger/src/main/java/com/roytuts/spring/boot/swagger/config/SwaggerConfig.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.boot.swagger.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 |
6 | import springfox.documentation.builders.ApiInfoBuilder;
7 | import springfox.documentation.builders.PathSelectors;
8 | import springfox.documentation.builders.RequestHandlerSelectors;
9 | import springfox.documentation.service.ApiInfo;
10 | import springfox.documentation.spi.DocumentationType;
11 | import springfox.documentation.spring.web.plugins.Docket;
12 | import springfox.documentation.swagger2.annotations.EnableSwagger2;
13 |
14 | @Configuration
15 | @EnableSwagger2
16 | public class SwaggerConfig {
17 |
18 | @Bean
19 | public Docket docket() {
20 | Docket docket = new Docket(DocumentationType.SWAGGER_2);
21 | docket.apiInfo(apiInfo()).select()
22 | .apis(RequestHandlerSelectors.basePackage("com.roytuts.spring.boot.swagger.rest.controller"))
23 | .paths(PathSelectors.any()).build();
24 | return docket;
25 | }
26 |
27 | private ApiInfo apiInfo() {
28 | return new ApiInfoBuilder().title("RESTful API").description("Browse and interact with RESTful API dynamically")
29 | .build();
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/spring-rest-optional-path-variable/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | spring-rest-optional-path-variable
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | UTF-8
14 | 19
15 | 19
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-parent
21 | 3.1.0
22 |
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-starter-web
27 |
28 |
29 |
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-maven-plugin
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/spring-rest-multiple-files-upload/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | spring-rest-multiple-files-upload
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | org.springframework.boot
14 | spring-boot-starter-parent
15 | 2.4.5
16 |
17 |
18 |
19 | UTF-8
20 | 12
21 | 12
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 |
31 |
32 |
33 |
34 | org.apache.maven.plugins
35 | maven-compiler-plugin
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/spring-rest-multiple-files-upload-client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | spring-rest-multiple-files-upload-client
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | UTF-8
14 | 19
15 | 19
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-parent
21 | 3.1.0
22 |
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-starter-web
27 |
28 |
29 |
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-maven-plugin
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/spring-concurrency-completablefuture/spring-concurrency-service-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | spring-concurrency-service-api
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | UTF-8
14 | 19
15 | 19
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-parent
21 | 3.1.0
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 |
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-maven-plugin
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/springboot-rest-api-multivaluemap/springboot-rest-api-multivaluemap/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | springboot-rest-api-multivaluemap
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | UTF-8
14 | 19
15 | 19
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-parent
21 | 3.4.0
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 |
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-maven-plugin
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/spring-concurrency-completablefuture/spring-concurrency-concurrent-calls/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | spring-concurrency-completablefuture
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | UTF-8
14 | 19
15 | 19
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-parent
21 | 3.1.0
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 |
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-maven-plugin
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/springboot-rest-api-multivaluemap/springboot-rest-api-multivaluemap-client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | springboot-rest-api-multivaluemap-client
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | UTF-8
14 | 19
15 | 19
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-parent
21 | 3.4.0
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 |
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-maven-plugin
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/spring-rest-junit-mvc/src/main/java/roytuts/model/Product.java:
--------------------------------------------------------------------------------
1 | package roytuts.model;
2 |
3 | public class Product {
4 |
5 | private int id;
6 |
7 | private String name;
8 |
9 | private double price;
10 |
11 | public Product() {
12 | }
13 |
14 | public Product(int id, String name, double price) {
15 | this.id = id;
16 | this.name = name;
17 | this.price = price;
18 | }
19 |
20 | public int getId() {
21 | return id;
22 | }
23 |
24 | public void setId(int id) {
25 | this.id = id;
26 | }
27 |
28 | public String getName() {
29 | return name;
30 | }
31 |
32 | public void setName(String name) {
33 | this.name = name;
34 | }
35 |
36 | public double getPrice() {
37 | return price;
38 | }
39 |
40 | public void setPrice(double price) {
41 | this.price = price;
42 | }
43 |
44 | @Override
45 |
46 | public int hashCode() {
47 | final int prime = 31;
48 | int result = 1;
49 | result = prime * result + (int) (id ^ (id >>> 32));
50 | return result;
51 | }
52 |
53 | @Override
54 | public boolean equals(Object obj) {
55 | if (this == obj)
56 | return true;
57 |
58 | if (obj == null)
59 | return false;
60 |
61 | if (getClass() != obj.getClass())
62 | return false;
63 |
64 | Product other = (Product) obj;
65 |
66 | if (id != other.id)
67 | return false;
68 |
69 | return true;
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/spring-rest-junit-complete/src/main/java/roytuts/model/Product.java:
--------------------------------------------------------------------------------
1 | package roytuts.model;
2 |
3 | public class Product {
4 |
5 | private int id;
6 |
7 | private String name;
8 |
9 | private double price;
10 |
11 | public Product() {
12 | }
13 |
14 | public Product(int id, String name, double price) {
15 | this.id = id;
16 | this.name = name;
17 | this.price = price;
18 | }
19 |
20 | public int getId() {
21 | return id;
22 | }
23 |
24 | public void setId(int id) {
25 | this.id = id;
26 | }
27 |
28 | public String getName() {
29 | return name;
30 | }
31 |
32 | public void setName(String name) {
33 | this.name = name;
34 | }
35 |
36 | public double getPrice() {
37 | return price;
38 | }
39 |
40 | public void setPrice(double price) {
41 | this.price = price;
42 | }
43 |
44 | @Override
45 |
46 | public int hashCode() {
47 | final int prime = 31;
48 | int result = 1;
49 | result = prime * result + (int) (id ^ (id >>> 32));
50 | return result;
51 | }
52 |
53 | @Override
54 | public boolean equals(Object obj) {
55 | if (this == obj)
56 | return true;
57 |
58 | if (obj == null)
59 | return false;
60 |
61 | if (getClass() != obj.getClass())
62 | return false;
63 |
64 | Product other = (Product) obj;
65 |
66 | if (id != other.id)
67 | return false;
68 |
69 | return true;
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/spring-rest-retry-recover/spring-rest-retry/src/main/java/com/roytuts/springrestretry/config/AppConfig.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.springrestretry.config;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.context.annotation.Bean;
5 | import org.springframework.context.annotation.Configuration;
6 | import org.springframework.retry.backoff.FixedBackOffPolicy;
7 | import org.springframework.retry.support.RetryTemplate;
8 | import org.springframework.web.client.RestTemplate;
9 |
10 | import com.roytuts.springrestretry.custom.CustomRetryPolicy;
11 |
12 | @Configuration
13 | public class AppConfig {
14 |
15 | @Value("${retry.maxAttempts:3}")
16 | private int maxAttempts;
17 |
18 | @Value("${retry.backoffInMillis:1000}")
19 | private long backoffInMillis;
20 |
21 | @Bean
22 | public RetryTemplate retryTemplate() {
23 | RetryTemplate retryTemplate = new RetryTemplate();
24 |
25 | FixedBackOffPolicy backOffPolicy = new FixedBackOffPolicy();
26 | backOffPolicy.setBackOffPeriod(backoffInMillis);
27 | retryTemplate.setBackOffPolicy(backOffPolicy);
28 |
29 | CustomRetryPolicy retryPolicy = new CustomRetryPolicy(maxAttempts);
30 | retryTemplate.setRetryPolicy(retryPolicy);
31 |
32 | return retryTemplate;
33 | }
34 |
35 | @Bean
36 | public RestTemplate restTemplate() {
37 | return new RestTemplate();
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/springboot-rest-api-multivaluemap/springboot-rest-api-multivaluemap-client/src/main/java/com/roytuts/springboot/rest/api/multivaluedmap/client/App.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.springboot.rest.api.multivaluemap.client;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.boot.CommandLineRunner;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
7 | import org.springframework.http.MediaType;
8 | import org.springframework.util.LinkedMultiValueMap;
9 | import org.springframework.util.MultiValueMap;
10 | import org.springframework.web.client.RestTemplate;
11 |
12 | @SpringBootApplication
13 | public class App implements CommandLineRunner {
14 |
15 | @Autowired
16 | private RestTemplate restTemplate;
17 |
18 | public static void main(String[] args) {
19 | SpringApplication.run(App.class, args).close();
20 | }
21 |
22 | @Override
23 | public void run(String... args) throws Exception {
24 | MultiValueMap map = new LinkedMultiValueMap<>();
25 | map.add("Accept-Encoding", "compress;q=0.5");
26 | map.add("Accept-Encoding", "gzip;q=1.0");
27 | map.add("Content-Type", MediaType.APPLICATION_JSON_VALUE);
28 |
29 | String response = restTemplate.postForObject("http://localhost:8080/multiValueMap", map, String.class);
30 |
31 | System.out.println("Response: " + response);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/spring-rest-https-certificate/spring-rest-https-client/src/main/java/com/roytuts/spring/rest/https/client/TempConverterRestClient.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.https.client;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.stereotype.Component;
5 | import org.springframework.web.client.RestTemplate;
6 |
7 | import com.roytuts.spring.rest.https.dto.Temperature;
8 | import com.roytuts.spring.rest.https.enums.TemperatureUnit;
9 |
10 | @Component
11 | public class TempConverterRestClient {
12 |
13 | @Autowired
14 | private RestTemplate restTemplate;
15 |
16 | public void temperature() {
17 | Temperature temperature = new Temperature();
18 | temperature.setValue(32.0);
19 | temperature.setUnit(TemperatureUnit.CELSIUS);
20 |
21 | // final String url = "http://localhost:8080/temperature";
22 | final String url = "https://localhost:8443/temperature";
23 |
24 | Temperature temp = restTemplate.postForObject(url, temperature, Temperature.class);
25 |
26 | System.out.println(temp.getValue() + " " + temp.getUnit().name());
27 |
28 | temperature = new Temperature();
29 | temperature.setValue(89.6);
30 | temperature.setUnit(TemperatureUnit.FAHRENHEIT);
31 |
32 | temp = restTemplate.postForObject(url, temperature, Temperature.class);
33 |
34 | System.out.println(temp.getValue() + " " + temp.getUnit().name());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/spring-resttemplate-proxy-timeout/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | spring-resttemplate-proxy-timeout
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | org.springframework.boot
14 | spring-boot-starter-parent
15 | 2.6.1
16 |
17 |
18 |
19 | UTF-8
20 | 16
21 | 16
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 |
31 | org.apache.httpcomponents
32 | httpclient
33 |
34 |
35 |
36 |
37 |
38 |
39 | org.springframework.boot
40 | spring-boot-maven-plugin
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/spring-rest-large-file-download/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | spring-rest-large-file-download
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | UTF-8
14 | 19
15 | 19
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-parent
21 | 3.1.5
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-starter-webflux
33 |
34 |
35 |
36 |
37 |
38 |
39 | org.springframework.boot
40 | spring-boot-maven-plugin
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/spring-rest-retry-recover/spring-rest-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | spring-rest-server
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | UTF-8
14 | 19
15 | 19
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-parent
21 | 3.2.4
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-devtools
33 | runtime
34 |
35 |
36 |
37 |
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-maven-plugin
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/spring-boot-angular-crud-rest-api/src/main/java/com/roytuts/spring/boot/angular/crud/rest/api/converter/EntityVoConverter.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.boot.angular.crud.rest.api.converter;
2 |
3 | import java.util.List;
4 | import java.util.stream.Collectors;
5 |
6 | import com.roytuts.spring.boot.angular.crud.rest.api.entity.Website;
7 | import com.roytuts.spring.boot.angular.crud.rest.api.vo.WebsiteVo;
8 |
9 | public final class EntityVoConverter {
10 |
11 | private EntityVoConverter() {
12 | }
13 |
14 | public static WebsiteVo convertEntityToVo(Website website) {
15 | WebsiteVo websiteVo = new WebsiteVo();
16 | websiteVo.setId(website.getId());
17 | websiteVo.setTitle(website.getTitle());
18 | websiteVo.setUrl(website.getUrl());
19 |
20 | return websiteVo;
21 | }
22 |
23 | public static Website convertVoToEntity(WebsiteVo websiteVo) {
24 | Website website = new Website();
25 | website.setId(websiteVo.getId());
26 | website.setTitle(websiteVo.getTitle());
27 | website.setUrl(websiteVo.getUrl());
28 |
29 | return website;
30 | }
31 |
32 | public static List convertEntityToVoList(List websites) {
33 | return websites.stream().map(w -> {
34 | return convertEntityToVo(w);
35 | }).collect(Collectors.toList());
36 | }
37 |
38 | public static List convertVoToEntityList(List websiteVos) {
39 | return websiteVos.stream().map(wvo -> {
40 | return convertVoToEntity(wvo);
41 | }).collect(Collectors.toList());
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/spring-rest-https-certificate/spring-rest-https-server/src/main/java/com/roytuts/spring/rest/https/rest/controller/TempConverterRestController.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.https.rest.controller;
2 |
3 | import org.springframework.http.HttpStatus;
4 | import org.springframework.http.ResponseEntity;
5 | import org.springframework.web.bind.annotation.PostMapping;
6 | import org.springframework.web.bind.annotation.RequestBody;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | import com.roytuts.spring.rest.https.dto.Temperature;
10 | import com.roytuts.spring.rest.https.enums.TemperatureUnit;
11 |
12 | @RestController
13 | public class TempConverterRestController {
14 |
15 | @PostMapping("/temperature")
16 | public ResponseEntity getTemperature(@RequestBody Temperature temperature) {
17 | Temperature temp = new Temperature();
18 |
19 | if (TemperatureUnit.CELSIUS == temperature.getUnit()) {
20 | double fahrenheit = (9.0 / 5.0) * temperature.getValue() + 32;
21 |
22 | temp.setValue(fahrenheit);
23 | temp.setUnit(TemperatureUnit.FAHRENHEIT);
24 | } else if (TemperatureUnit.FAHRENHEIT == temperature.getUnit()) {
25 | double celsius = (5.0 / 9.0) * (temperature.getValue() - 32);
26 |
27 | temp.setValue(celsius);
28 | temp.setUnit(TemperatureUnit.CELSIUS);
29 | } else {
30 | throw new IllegalArgumentException("Illegal Argument");
31 | }
32 |
33 | return new ResponseEntity(temp, HttpStatus.OK);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/spring-openapi-documentation/api-docs.yaml:
--------------------------------------------------------------------------------
1 | openapi: 3.0.1
2 | info:
3 | title: OpenAPI definition
4 | version: v0
5 | servers:
6 | - url: http://localhost:8080
7 | description: Generated server url
8 | paths:
9 | /greet:
10 | post:
11 | tags:
12 | - rest-api
13 | summary: Returns a response as Hello with a name
14 | description: This POST operation returns a response as Hello with a given name
15 | operationId: greet
16 | requestBody:
17 | content:
18 | application/json:
19 | schema:
20 | type: string
21 | required: true
22 | responses:
23 | "200":
24 | description: SUCCESS
25 | content:
26 | '*/*':
27 | schema:
28 | type: string
29 | "500":
30 | description: FAILURE
31 | content:
32 | '*/*':
33 | schema:
34 | type: string
35 | /:
36 | get:
37 | tags:
38 | - rest-api
39 | summary: Returns a response as Hello World!
40 | description: This GET operation returns a response as Hello World!
41 | operationId: greet_1
42 | responses:
43 | "200":
44 | description: SUCCESS
45 | content:
46 | '*/*':
47 | schema:
48 | type: string
49 | "500":
50 | description: FAILURE
51 | content:
52 | '*/*':
53 | schema:
54 | type: string
55 | components: {}
56 |
--------------------------------------------------------------------------------
/spring-hateoas/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | spring-hateoas
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | UTF-8
14 | 12
15 | 12
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-parent
21 | 2.4.5
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-hateoas
28 |
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-starter-data-jpa
33 |
34 |
35 |
36 | com.h2database
37 | h2
38 |
39 |
40 |
41 |
42 |
43 |
44 | org.springframework.boot
45 | spring-boot-maven-plugin
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/spring-openapi-documentation/pom.xml_3.5.4:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | spring-openapi-documentation
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | UTF-8
14 | 22
15 |
16 |
17 |
18 | org.springframework.boot
19 | spring-boot-starter-parent
20 | 3.5.4
21 |
22 |
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-starter-web
27 |
28 |
29 |
30 | org.springdoc
31 | springdoc-openapi-starter-webmvc-ui
32 | 2.8.9
33 |
34 |
35 |
36 | jakarta.servlet
37 | jakarta.servlet-api
38 |
39 |
40 |
41 |
42 |
43 |
44 | org.springframework.boot
45 | spring-boot-maven-plugin
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/spring-rest-file-download/spring-boot-3/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | spring-rest-file-download
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | UTF-8
14 | 19
15 | 19
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-parent
21 | 3.1.5
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-starter-data-jpa
33 |
34 |
35 |
36 | com.mysql
37 | mysql-connector-j
38 |
39 |
40 |
41 |
42 |
43 |
44 | org.springframework.boot
45 | spring-boot-maven-plugin
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/spring-openapi-documentation/pom.xml_3_2_5:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | spring-openapi-documentation
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | UTF-8
14 | 19
15 | 19
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-parent
21 | 3.2.5
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 |
31 | org.springdoc
32 | springdoc-openapi-starter-webmvc-ui
33 | 2.5.0
34 |
35 |
36 |
37 | jakarta.servlet
38 | jakarta.servlet-api
39 |
40 |
41 |
42 |
43 |
44 |
45 | org.springframework.boot
46 | spring-boot-maven-plugin
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/spring-rest-file-download/src/main/java/com/roytuts/controller/FileDownloadRestController.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.controller;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.http.HttpHeaders;
7 | import org.springframework.http.HttpStatus;
8 | import org.springframework.http.MediaType;
9 | import org.springframework.http.ResponseEntity;
10 | import org.springframework.web.bind.annotation.GetMapping;
11 | import org.springframework.web.bind.annotation.RestController;
12 |
13 | import com.fasterxml.jackson.databind.ObjectMapper;
14 | import com.roytuts.entity.Employee;
15 | import com.roytuts.service.EmployeeService;
16 |
17 | @RestController
18 | public class FileDownloadRestController {
19 |
20 | @Autowired
21 | private EmployeeService employeeService;
22 |
23 | @GetMapping("/download")
24 | public ResponseEntity downloadErrorData() throws Exception {
25 | List employees = employeeService.getEmployees();
26 | ObjectMapper objectMapper = new ObjectMapper();
27 | String json = objectMapper.writeValueAsString(employees);
28 | byte[] isr = json.getBytes();
29 | String fileName = "employees.json";
30 | HttpHeaders respHeaders = new HttpHeaders();
31 | respHeaders.setContentLength(isr.length);
32 | respHeaders.setContentType(new MediaType("text", "json"));
33 | respHeaders.setCacheControl("must-revalidate, post-check=0, pre-check=0");
34 | respHeaders.set(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + fileName);
35 | return new ResponseEntity(isr, respHeaders, HttpStatus.OK);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/spring-openapi-documentation/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.roytuts
9 | spring-openapi-documentation
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | UTF-8
14 | 19
15 | 19
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-parent
21 | 3.1.0
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 |
31 | org.springdoc
32 | springdoc-openapi-starter-webmvc-ui
33 | 2.1.0
34 |
35 |
36 |
37 | javax.servlet
38 | javax.servlet-api
39 | 4.0.1
40 | provided
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.boot
48 | spring-boot-maven-plugin
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/spring-rest-file-upload/src/main/java/com/roytuts/spring/rest/file/upload/controller/FileUploadRestController.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.rest.file.upload.controller;
2 |
3 | import java.io.InputStream;
4 |
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 | import org.springframework.http.HttpStatus;
8 | import org.springframework.http.ResponseEntity;
9 | import org.springframework.web.bind.annotation.PostMapping;
10 | import org.springframework.web.bind.annotation.RequestParam;
11 | import org.springframework.web.bind.annotation.RestController;
12 | import org.springframework.web.multipart.MultipartFile;
13 |
14 | @RestController
15 | public class FileUploadRestController {
16 |
17 | private static final Logger logger = LoggerFactory.getLogger(FileUploadRestController.class.getName());
18 |
19 | @PostMapping("/upload")
20 | public ResponseEntity uploadData(@RequestParam("file") MultipartFile file) throws Exception {
21 |
22 | if (file == null) {
23 | throw new RuntimeException("You must select the a file for uploading");
24 | }
25 |
26 | InputStream inputStream = file.getInputStream();
27 | String originalName = file.getOriginalFilename();
28 | String name = file.getName();
29 | String contentType = file.getContentType();
30 | long size = file.getSize();
31 |
32 | logger.info("inputStream: " + inputStream);
33 | logger.info("originalName: " + originalName);
34 | logger.info("name: " + name);
35 | logger.info("contentType: " + contentType);
36 | logger.info("size: " + size);
37 |
38 | // Do processing with uploaded file data in Service layer
39 | return new ResponseEntity(originalName, HttpStatus.OK);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/spring-online-visitor-tracker/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | com.roytuts
6 | spring-online-visitor-tracker
7 | 0.0.1-SNAPSHOT
8 | jar
9 |
10 |
11 | UTF-8
12 | 8
13 | 8
14 |
15 |
16 |
17 | org.springframework.boot
18 | spring-boot-starter-parent
19 | 2.5.4
20 |
21 |
22 |
23 |
24 | org.springframework.boot
25 | spring-boot-starter-web
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-security
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-data-jpa
36 |
37 |
38 |
39 | com.h2database
40 | h2
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.boot
48 | spring-boot-maven-plugin
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/spring-web-exception-handling/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 4.0.0
5 |
6 | com.roytuts
7 | spring-web-exception-handling
8 | 0.0.1-SNAPSHOT
9 |
10 |
11 | UTF-8
12 | 11
13 | 11
14 |
15 |
16 |
17 | org.springframework.boot
18 | spring-boot-starter-parent
19 | 2.6.6
20 |
21 |
22 |
23 |
24 | org.springframework.boot
25 | spring-boot-starter-web
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-devtools
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-data-jpa
36 |
37 |
38 |
39 | com.h2database
40 | h2
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.boot
48 | spring-boot-maven-plugin
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/spring-resttemplate-proxy-timeout/src/main/java/com/roytuts/spring/resttemplate/proxy/timeout/RestApiController.java:
--------------------------------------------------------------------------------
1 | package com.roytuts.spring.resttemplate.proxy.timeout;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.http.HttpEntity;
5 | import org.springframework.http.HttpHeaders;
6 | import org.springframework.http.HttpStatus;
7 | import org.springframework.http.ResponseEntity;
8 | import org.springframework.web.bind.annotation.GetMapping;
9 | import org.springframework.web.bind.annotation.PostMapping;
10 | import org.springframework.web.bind.annotation.RequestBody;
11 | import org.springframework.web.bind.annotation.RestController;
12 | import org.springframework.web.client.RestTemplate;
13 |
14 | @RestController
15 | public class RestApiController {
16 |
17 | @Autowired
18 | private RestTemplate restTemplate;
19 |
20 | @GetMapping("/fetch")
21 | public ResponseEntity