├── springboot-examples ├── springboot-flyway │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── db │ │ │ │ └── migration │ │ │ │ │ ├── V1.3__delete_book.sql │ │ │ │ │ ├── V1.1__insert_book.sql │ │ │ │ │ ├── V1.2__insert_book.sql │ │ │ │ │ └── V1.0__create_book.sql │ │ │ └── application.properties │ │ │ └── java │ │ │ └── com │ │ │ └── hellokoding │ │ │ └── springboot │ │ │ └── jpa │ │ │ ├── book │ │ │ ├── Product.java │ │ │ ├── BookRepository.java │ │ │ └── Book.java │ │ │ └── Application.java │ └── docker-compose.yml ├── springboot-mapstruct │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── springboot │ │ │ │ └── restful │ │ │ │ ├── product │ │ │ │ ├── ProductRespository.java │ │ │ │ ├── ProductDTO.java │ │ │ │ └── ProductMapper.java │ │ │ │ └── Application.java │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── springboot-swagger │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── springboot │ │ │ │ └── restful │ │ │ │ └── product │ │ │ │ ├── ProductRespository.java │ │ │ │ ├── ProductDTO.java │ │ │ │ └── ProductMapper.java │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── springboot-caching-redis │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── springboot │ │ │ │ └── caching │ │ │ │ ├── product │ │ │ │ ├── ProductRepository.java │ │ │ │ └── Product.java │ │ │ │ ├── Application.java │ │ │ │ └── configuration │ │ │ │ ├── CustomKeyGenerator.java │ │ │ │ └── CachingConfiguration.java │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── springboot-crud-mysql-vuejs │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── static │ │ │ │ └── products.css │ │ │ └── application.properties │ │ │ └── java │ │ │ └── com │ │ │ └── hellokoding │ │ │ └── springboot │ │ │ └── restful │ │ │ ├── product │ │ │ ├── ProductRespository.java │ │ │ └── ProductController.java │ │ │ └── Application.java │ └── docker-compose.yml ├── springdatarest-mysql-single │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── springdatarest │ │ │ │ ├── book │ │ │ │ ├── BookRepository.java │ │ │ │ └── Book.java │ │ │ │ └── Application.java │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── springboot-registration-login │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── auth │ │ │ │ ├── service │ │ │ │ ├── SecurityService.java │ │ │ │ └── UserService.java │ │ │ │ ├── repository │ │ │ │ ├── RoleRepository.java │ │ │ │ └── UserRepository.java │ │ │ │ └── WebApplication.java │ │ │ └── resources │ │ │ ├── validation.properties │ │ │ └── application.properties │ └── docker-compose.yml ├── springboot-todomvc-mysql-vuejs │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── static │ │ │ │ └── todo.css │ │ │ └── application.properties │ │ │ └── java │ │ │ └── com │ │ │ └── hellokoding │ │ │ └── springboot │ │ │ └── fullstack │ │ │ ├── todo │ │ │ ├── TodoRepository.java │ │ │ ├── TodoController.java │ │ │ ├── TodoService.java │ │ │ └── Todo.java │ │ │ └── Application.java │ └── docker-compose.yml ├── springboot-restapi-testing-all-layers │ ├── Dockerfile │ ├── src │ │ ├── test │ │ │ └── resources │ │ │ │ └── application.properties │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── springboot │ │ │ │ └── restful │ │ │ │ ├── product │ │ │ │ ├── ProductRespository.java │ │ │ │ ├── ProductMapper.java │ │ │ │ └── ProductDTO.java │ │ │ │ └── Application.java │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── scribejava-oauth2 │ ├── .gitignore │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── springboot │ │ └── oauth2 │ │ └── OAuth2Application.java ├── springboot-email-verification-mysql │ ├── Dockerfile │ ├── .gitignore │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── static │ │ │ │ ├── css │ │ │ │ │ └── main.css │ │ │ │ └── js │ │ │ │ │ └── main.js │ │ │ └── templates │ │ │ │ └── email-verification.ftl │ │ │ └── java │ │ │ └── com │ │ │ └── hellokoding │ │ │ └── account │ │ │ ├── repository │ │ │ ├── UserRepository.java │ │ │ └── VerificationTokenRepository.java │ │ │ ├── WebApplication.java │ │ │ └── model │ │ │ └── VerificationForm.java │ └── docker-compose.yaml ├── spring-security-oauth2 │ ├── .gitignore │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── springboot │ │ └── oauth2 │ │ ├── OAuth2Application.java │ │ └── OAuth2Controller.java ├── springdatarest-mysql-many-to-many │ ├── .gitignore │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── hellokoding │ │ │ └── restfulapi │ │ │ ├── repository │ │ │ ├── BookRepository.java │ │ │ └── AuthorRepository.java │ │ │ └── Application.java │ │ └── resources │ │ └── application.properties ├── springdatarest-mysql-one-to-many │ ├── .gitignore │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── hellokoding │ │ │ └── restfulapi │ │ │ ├── repository │ │ │ ├── BookRepository.java │ │ │ └── BookCategoryRepository.java │ │ │ └── Application.java │ │ └── resources │ │ └── application.properties ├── springdatarest-mysql-many-to-many-extra-columns │ ├── .gitignore │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── hellokoding │ │ │ └── restfulapi │ │ │ ├── repository │ │ │ ├── BookRepository.java │ │ │ ├── PublisherRepository.java │ │ │ └── BookPublisherRepository.java │ │ │ └── Application.java │ │ └── resources │ │ └── application.properties ├── springboot-jsp-helloworld │ └── src │ │ └── main │ │ ├── resources │ │ ├── static │ │ │ ├── css │ │ │ │ └── main.css │ │ │ └── js │ │ │ │ └── main.js │ │ └── application.properties │ │ ├── webapp │ │ └── WEB-INF │ │ │ └── jsp │ │ │ └── hello.jsp │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── springboot │ │ └── view │ │ ├── Application.java │ │ └── HelloController.java ├── springboot-freemarker-helloworld │ └── src │ │ └── main │ │ ├── resources │ │ ├── static │ │ │ ├── css │ │ │ │ └── main.css │ │ │ └── js │ │ │ │ └── main.js │ │ ├── application.properties │ │ └── templates │ │ │ └── hello.ftlh │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── springboot │ │ └── view │ │ ├── Application.java │ │ └── HelloController.java ├── springboot-thymeleaf-helloworld │ └── src │ │ └── main │ │ ├── resources │ │ ├── static │ │ │ ├── css │ │ │ │ └── main.css │ │ │ └── js │ │ │ │ └── main.js │ │ ├── application.properties │ │ └── templates │ │ │ └── hello.html │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── springboot │ │ └── view │ │ ├── Application.java │ │ └── HelloController.java ├── springboot-freemarker-form-contact │ ├── .gitignore │ └── src │ │ └── main │ │ ├── resources │ │ ├── static │ │ │ ├── js │ │ │ │ └── main.js │ │ │ └── css │ │ │ │ └── main.css │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── form │ │ ├── service │ │ └── SendingMailService.java │ │ └── WebApplication.java ├── springboot-freemarker-form-submission │ ├── .gitignore │ └── src │ │ └── main │ │ ├── resources │ │ ├── static │ │ │ ├── js │ │ │ │ └── main.js │ │ │ └── css │ │ │ │ └── main.css │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── springboot │ │ ├── WebApplication.java │ │ ├── User.java │ │ └── FormController.java ├── springboot-freemarker-form-validation │ ├── .gitignore │ └── src │ │ └── main │ │ ├── resources │ │ ├── static │ │ │ ├── js │ │ │ │ └── main.js │ │ │ └── css │ │ │ │ └── main.css │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── springboot │ │ └── WebApplication.java ├── springboot-nested-properties-file │ └── src │ │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── util │ │ ├── SimpleProperties.java │ │ └── NestedProperties.java ├── springboot-security-login-thymeleaf │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ ├── static │ │ │ │ │ └── js │ │ │ │ │ │ └── main.js │ │ │ │ ├── application.properties │ │ │ │ └── validation.properties │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── tutorials │ │ │ │ ├── service │ │ │ │ ├── SecurityService.java │ │ │ │ └── UserService.java │ │ │ │ ├── repository │ │ │ │ ├── RoleRepository.java │ │ │ │ └── UserRepository.java │ │ │ │ └── DemoApplication.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── hellokoding │ │ │ └── tutorials │ │ │ └── DemoApplicationTests.java │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ └── .gitignore ├── springboot-single-sign-on-jwt │ ├── resources-service │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ ├── application.properties │ │ │ │ └── templates │ │ │ │ └── protected-resource.ftl │ │ └── .gitignore │ └── auth-service │ │ ├── .gitignore │ │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── hellokoding │ │ │ └── sso │ │ │ └── auth │ │ │ └── WebApplication.java │ │ └── resources │ │ └── templates │ │ └── login.ftl ├── springboot-uploading-files │ ├── .gitignore │ └── src │ │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── uploadingfiles │ │ └── Application.java ├── springboot-single-sign-out-jwt │ ├── auth-service │ │ ├── .gitignore │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── sso │ │ │ │ └── auth │ │ │ │ └── WebApplication.java │ │ │ └── resources │ │ │ └── templates │ │ │ └── login.ftl │ └── resources-service │ │ ├── src │ │ └── main │ │ │ └── resources │ │ │ ├── application.properties │ │ │ └── templates │ │ │ └── protected-resource.ftl │ │ └── .gitignore ├── lombok-example │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── springboot │ │ └── product │ │ ├── Main.java │ │ └── Product.java ├── springboot-mockmvc-hsql │ └── src │ │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── springboot │ │ └── restful │ │ ├── StockRepository.java │ │ ├── StockController.java │ │ ├── Application.java │ │ └── Stock.java ├── springboot-restapi-validation │ └── src │ │ └── main │ │ ├── resources │ │ └── ValidationMessages.properties │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── springboot │ │ └── restful │ │ ├── product │ │ ├── ProductRepository.java │ │ ├── ProductIDExisting.java │ │ └── ProductIDExistingValidator.java │ │ ├── ResponseDTO.java │ │ └── Application.java ├── springboot-actuator │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── application.properties │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── springboot │ │ │ │ └── SpringbootActuatorApplication.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── hellokoding │ │ │ └── springboot │ │ │ └── SpringbootActuatorApplicationTests.java │ └── .gitignore ├── springboot-restapi │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── springboot │ │ └── restful │ │ ├── product │ │ └── ProductRepository.java │ │ └── Application.java └── spring-core-examples │ └── src │ └── main │ └── java │ └── com │ └── hellokoding │ └── springcore │ ├── ConsumerService.java │ └── RestTemplateWithErrorHandlerConfig.java ├── docker-examples ├── dockercompose-springboot-mongodb-nginx │ ├── .gitignore │ ├── app │ │ ├── Dockerfile │ │ ├── .gitignore │ │ └── src │ │ │ └── main │ │ │ ├── resources │ │ │ ├── static │ │ │ │ ├── css │ │ │ │ │ └── main.css │ │ │ │ └── js │ │ │ │ │ └── main.js │ │ │ ├── application.properties │ │ │ └── templates │ │ │ │ └── index.ftl │ │ │ └── java │ │ │ └── com │ │ │ └── hellokoding │ │ │ └── springboot │ │ │ └── WebApplication.java │ └── nginx │ │ └── conf.d │ │ └── app.conf ├── dockercompose-springboot-nginx │ ├── app │ │ ├── Dockerfile │ │ ├── .gitignore │ │ └── src │ │ │ └── main │ │ │ ├── resources │ │ │ ├── static │ │ │ │ ├── css │ │ │ │ │ └── main.css │ │ │ │ └── js │ │ │ │ │ └── main.js │ │ │ ├── application.properties │ │ │ └── templates │ │ │ │ └── index.ftl │ │ │ └── java │ │ │ └── com │ │ │ └── hellokoding │ │ │ └── springboot │ │ │ ├── WebApplication.java │ │ │ └── IndexController.java │ ├── docker-compose.yaml │ └── nginx │ │ └── conf.d │ │ └── app.conf ├── dockercompose-springboot-mysql-nginx │ ├── app │ │ ├── Dockerfile │ │ ├── .gitignore │ │ └── src │ │ │ └── main │ │ │ ├── resources │ │ │ ├── static │ │ │ │ ├── css │ │ │ │ │ └── main.css │ │ │ │ └── js │ │ │ │ │ └── main.js │ │ │ ├── templates │ │ │ │ └── index.ftl │ │ │ └── application.properties │ │ │ └── java │ │ │ └── com │ │ │ └── hellokoding │ │ │ └── springboot │ │ │ ├── WebApplication.java │ │ │ └── IndexController.java │ └── nginx │ │ └── conf.d │ │ └── app.conf └── docker-compose-nginx-jetty-mysql │ ├── nginx-site-enabled │ └── default │ └── docker-compose.yaml ├── java-examples ├── javamail-awsses │ └── .gitignore ├── javamail-gmail │ └── .gitignore ├── java-app-healthcheck-prometheus │ ├── Dockerfile │ ├── .gitignore │ ├── prometheus.yml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── monitoring │ │ └── Application.java ├── java-properties-file │ ├── .gitignore │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.properties │ │ │ └── java │ │ │ └── com │ │ │ └── hellokoding │ │ │ └── util │ │ │ └── Main.java │ └── pom.xml ├── java-jooq-mysql │ ├── .gitignore │ ├── create_db.sql │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── jooq │ │ └── model │ │ └── Tables.java ├── java-core │ └── src │ │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── hellokoding │ │ │ └── java │ │ │ ├── lang │ │ │ ├── BookWithoutEquals.java │ │ │ └── BookWithEquals.java │ │ │ ├── collections │ │ │ ├── NonComparableBook.java │ │ │ ├── ComparableBook.java │ │ │ └── Java9CollectionFactoryMethodsTest.java │ │ │ ├── java14 │ │ │ ├── HelpfulNullPointerException.java │ │ │ └── Records.java │ │ │ └── concurrent │ │ │ ├── CompletableFutureGetVsJoinTest.java │ │ │ ├── CallableCounter.java │ │ │ ├── ThreadCounter.java │ │ │ └── RunnableCounter.java │ │ └── main │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── java │ │ └── collections │ │ ├── StringSortAscending.java │ │ └── StringSortDescendingByStringBuilder.java └── java-bean-validation │ └── src │ └── main │ ├── resources │ └── ValidationMessages.properties │ └── java │ └── com │ └── hellokoding │ └── validation │ ├── ProductCodeExistingValidator.java │ └── ProductCodeExisting.java ├── jpa-hibernate-examples ├── jpa-hibernate-problems │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── jpa-hibernate-deleting-data │ ├── Dockerfile │ └── src │ │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── jpa │ │ └── customer │ │ ├── CardRepository.java │ │ └── CardService.java ├── jpa-hibernate-crud-deleting-entity │ ├── Dockerfile │ └── src │ │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── jpa │ │ ├── book │ │ ├── CategoryRepository.java │ │ └── BookRepository.java │ │ └── JpaApplication.java ├── jpa-hibernate-crud-querying-entity │ ├── Dockerfile │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── hellokoding │ │ │ └── jpa │ │ │ └── book │ │ │ ├── CategoryRepository.java │ │ │ └── BookRepository.java │ │ └── resources │ │ └── application.properties ├── jpa-hibernate-many-to-many-mysql │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── jpa │ │ │ │ └── book │ │ │ │ ├── BookRepository.java │ │ │ │ ├── PublisherRepository.java │ │ │ │ └── Publisher.java │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── jpa-hibernate-one-to-many-mysql │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── jpa │ │ │ │ └── book │ │ │ │ └── BookCategoryRepository.java │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── jpa-hibernate-one-to-one-mysql │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── jpa │ │ │ │ ├── repository │ │ │ │ └── PersonRepository.java │ │ │ │ └── model │ │ │ │ ├── IDCard.java │ │ │ │ └── Person.java │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── springboot-mapstruct-onetomany │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── springboot │ │ │ │ ├── LibraryMapper.java │ │ │ │ ├── BookRepository.java │ │ │ │ ├── LibraryRepository.java │ │ │ │ ├── unidirectional │ │ │ │ ├── LibraryRepository.java │ │ │ │ ├── Application.java │ │ │ │ └── BookRepository.java │ │ │ │ └── Application.java │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── jpa-hibernate-one-to-many-mysql-rest │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── jpa │ │ │ │ ├── bidirectional │ │ │ │ ├── BookRepository.java │ │ │ │ ├── LibraryRepository.java │ │ │ │ └── Application.java │ │ │ │ └── unidirectional │ │ │ │ ├── LibraryRepository.java │ │ │ │ ├── Application.java │ │ │ │ └── BookRepository.java │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── jpa-hibernate-circular-reference-jackson │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── jpa │ │ │ │ ├── book │ │ │ │ ├── BookRepository.java │ │ │ │ ├── AuthorRepository.java │ │ │ │ ├── CategoryRepository.java │ │ │ │ ├── PublisherRepository.java │ │ │ │ ├── BookPublisherRepository.java │ │ │ │ ├── Author.java │ │ │ │ ├── Category.java │ │ │ │ ├── BookPublisher.java │ │ │ │ └── Publisher.java │ │ │ │ └── JpaApplication.java │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── jpa-hibernate-composite-primary-key-mysql │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── jpa │ │ │ │ ├── EmployeeRepository.java │ │ │ │ ├── EmployeePhoneId.java │ │ │ │ └── EmployeePhone.java │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── jpa-hibernate-many-to-many-extra-columns-mysql │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── jpa │ │ │ │ └── book │ │ │ │ ├── BookRepository.java │ │ │ │ ├── PublisherRepository.java │ │ │ │ └── Publisher.java │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── jpa-hibernate-one-to-one-shared-primary-key-mysql │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── jpa │ │ │ │ ├── repository │ │ │ │ └── PersonRepository.java │ │ │ │ └── model │ │ │ │ ├── IDCard.java │ │ │ │ └── Person.java │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── jpa-hibernate-many-to-many-extra-columns-mysql-rest │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── jpa │ │ │ │ ├── book │ │ │ │ ├── BookRepository.java │ │ │ │ ├── PublisherRepository.java │ │ │ │ ├── BookPublisherRepository.java │ │ │ │ ├── Publisher.java │ │ │ │ └── Book.java │ │ │ │ └── JpaApplication.java │ │ │ └── resources │ │ │ └── application.properties │ └── docker-compose.yml ├── jpa-hibernate-one-to-many-hsql │ ├── .gitignore │ └── src │ │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── hellokoding │ │ └── jpa │ │ └── repository │ │ └── BookCategoryRepository.java ├── jpa-hibernate-one-to-one-hsql │ ├── .gitignore │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── hellokoding │ │ │ └── jpa │ │ │ ├── repository │ │ │ ├── IDCardRepository.java │ │ │ └── PersonRepository.java │ │ │ └── model │ │ │ ├── Person.java │ │ │ └── IDCard.java │ │ └── resources │ │ └── application.properties ├── jpa-hibernate-many-to-many-hsql │ ├── .gitignore │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── hellokoding │ │ │ └── jpa │ │ │ ├── repository │ │ │ ├── BookRepository.java │ │ │ ├── PublisherRepository.java │ │ │ └── BookPublisherRepository.java │ │ │ └── model │ │ │ ├── Publisher.java │ │ │ └── Book.java │ │ └── resources │ │ └── application.properties ├── jpa-hibernate-many-to-many-extra-columns-hsql │ ├── .gitignore │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── hellokoding │ │ │ └── jpa │ │ │ ├── repository │ │ │ ├── BookRepository.java │ │ │ ├── PublisherRepository.java │ │ │ └── BookPublisherRepository.java │ │ │ └── model │ │ │ ├── BookPublisherId.java │ │ │ ├── Publisher.java │ │ │ └── Book.java │ │ └── resources │ │ └── application.properties └── jpa-hibernate-one-to-one-shared-primary-key-hsql │ ├── .gitignore │ └── src │ └── main │ ├── resources │ └── application.properties │ └── java │ └── com │ └── hellokoding │ └── jpa │ └── repository │ └── BookRepository.java ├── spring-examples ├── spring-webflux │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── application.properties │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── hellokoding │ │ │ │ └── spring │ │ │ │ ├── HelloApplication.java │ │ │ │ └── HelloHandler.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── hellokoding │ │ │ └── spring │ │ │ └── HelloApplicationTests.java │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ └── .gitignore └── spring-aop-example │ └── src │ ├── main │ └── java │ │ └── com │ │ └── hellokoding │ │ └── spring │ │ ├── LogExecutionTime.java │ │ └── Application.java │ └── test │ └── java │ └── com │ └── hellokoding │ └── spring │ └── Foo.java ├── spring-mvc-examples ├── springmvc-xml-jsp │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── application.properties │ │ │ └── logback.xml │ │ │ ├── webapp │ │ │ ├── resources │ │ │ │ ├── css │ │ │ │ │ └── main.css │ │ │ │ └── js │ │ │ │ │ └── main.js │ │ │ └── WEB-INF │ │ │ │ ├── views │ │ │ │ └── hello.jsp │ │ │ │ └── appconfig-root.xml │ │ │ └── java │ │ │ └── com │ │ │ └── hellokoding │ │ │ └── springmvc │ │ │ └── HelloController.java │ └── .gitignore ├── springmvc-xml-thymeleaf │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── application.properties │ │ │ └── logback.xml │ │ │ ├── webapp │ │ │ ├── resources │ │ │ │ ├── css │ │ │ │ │ └── main.css │ │ │ │ └── js │ │ │ │ │ └── main.js │ │ │ └── WEB-INF │ │ │ │ ├── views │ │ │ │ └── hello.html │ │ │ │ └── appconfig-root.xml │ │ │ └── java │ │ │ └── com │ │ │ └── hellokoding │ │ │ └── springmvc │ │ │ └── HelloController.java │ └── .gitignore └── registration-login-spring-xml-maven-jsp-mysql │ └── src │ └── main │ ├── java │ └── com │ │ └── hellokoding │ │ └── account │ │ ├── service │ │ ├── SecurityService.java │ │ └── UserService.java │ │ └── repository │ │ ├── RoleRepository.java │ │ └── UserRepository.java │ └── resources │ ├── application.properties │ ├── validation.properties │ └── logback.xml ├── .gitignore ├── README.md └── datastructure-algorithm-java-examples ├── src └── main │ └── java │ └── com │ └── hellokoding │ ├── algorithm │ ├── LongestSubstringWithoutRepeatingCharsWS.java │ ├── FibonacciRecursion.java │ ├── FibonacciTabular.java │ ├── BinarySearch.java │ ├── FibonacciMemoization.java │ ├── SmallestMissingPositiveNumberBySorting.java │ ├── SubarrayMaxSumBruteforce.java │ ├── SubarrayMaxSumWindowSliding.java │ ├── BinaryTreeHeight.java │ ├── ReverseWordsBySplittingAndIterative.java │ ├── AnagramsBySorting.java │ └── ReverseWordsByIterative.java │ └── datastructure │ ├── Array1D.java │ └── Array2D.java └── pom.xml /springboot-examples/springboot-flyway/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mongodb-nginx/.gitignore: -------------------------------------------------------------------------------- 1 | data -------------------------------------------------------------------------------- /java-examples/javamail-awsses/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | target 3 | *.iml 4 | -------------------------------------------------------------------------------- /java-examples/javamail-gmail/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | target 3 | *.iml 4 | -------------------------------------------------------------------------------- /springboot-examples/springboot-mapstruct/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /springboot-examples/springboot-swagger/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /java-examples/java-app-healthcheck-prometheus/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-problems/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /spring-examples/spring-webflux/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /springboot-examples/springboot-caching-redis/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /springboot-examples/springboot-crud-mysql-vuejs/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-single/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /java-examples/java-app-healthcheck-prometheus/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | target 3 | *.iml -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-deleting-data/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-jsp/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-examples/springboot-registration-login/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /springboot-examples/springboot-todomvc-mysql-vuejs/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-nginx/app/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 2 | -------------------------------------------------------------------------------- /java-examples/java-properties-file/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | target 3 | *.iml 4 | out 5 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-crud-deleting-entity/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-crud-querying-entity/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-mysql/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-mysql/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-mysql/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /jpa-hibernate-examples/springboot-mapstruct-onetomany/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-thymeleaf/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi-testing-all-layers/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mysql-nginx/app/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 2 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-mysql-rest/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-jsp/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml 3 | target 4 | *.DS_Store -------------------------------------------------------------------------------- /springboot-examples/scribejava-oauth2/.gitignore: -------------------------------------------------------------------------------- 1 | config 2 | .env 3 | target 4 | .idea 5 | -------------------------------------------------------------------------------- /springboot-examples/springboot-email-verification-mysql/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 2 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mongodb-nginx/app/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 2 | -------------------------------------------------------------------------------- /java-examples/java-properties-file/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | app.name=Hello Koding -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-circular-reference-jackson/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-composite-primary-key-mysql/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-thymeleaf/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml 3 | target 4 | *.DS_Store -------------------------------------------------------------------------------- /springboot-examples/spring-security-oauth2/.gitignore: -------------------------------------------------------------------------------- 1 | config 2 | .env 3 | target 4 | .idea 5 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-many-to-many/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | *.iml 3 | .idea 4 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-one-to-many/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | *.iml 3 | .idea 4 | -------------------------------------------------------------------------------- /java-examples/java-jooq-mysql/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml 3 | target 4 | *.DS_Store 5 | .mvn 6 | mvn* -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-mysql/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-shared-primary-key-mysql/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-mysql-rest/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /springboot-examples/springboot-todomvc-mysql-vuejs/src/main/resources/static/todo.css: -------------------------------------------------------------------------------- 1 | [v-cloak] { display: none; } -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-many-to-many-extra-columns/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | *.iml 3 | .idea 4 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-nginx/app/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | target 3 | *.iml 4 | out 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mongodb-nginx/app/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | target 3 | *.iml 4 | out 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mysql-nginx/app/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | target 3 | *.iml 4 | out 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-hsql/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml 3 | target 4 | *.DS_Store 5 | .mvn 6 | mvn* -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-hsql/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml 3 | target 4 | *.DS_Store 5 | .mvn 6 | mvn* -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-jsp/src/main/webapp/resources/css/main.css: -------------------------------------------------------------------------------- 1 | .hello-title{ 2 | color: darkgreen; 3 | } -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-hsql/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml 3 | target 4 | *.DS_Store 5 | .mvn 6 | mvn* -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-thymeleaf/src/main/webapp/resources/css/main.css: -------------------------------------------------------------------------------- 1 | .hello-title{ 2 | color: darkgreen; 3 | } -------------------------------------------------------------------------------- /springboot-examples/springboot-email-verification-mysql/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | target 3 | *.iml 4 | out 5 | .DS_Store 6 | data 7 | -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-jsp/src/main/webapp/resources/js/main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | console.log("Hello World!"); 3 | })(); -------------------------------------------------------------------------------- /springboot-examples/springboot-jsp-helloworld/src/main/resources/static/css/main.css: -------------------------------------------------------------------------------- 1 | .hello-title{ 2 | color: darkgreen; 3 | } -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-nginx/app/src/main/resources/static/css/main.css: -------------------------------------------------------------------------------- 1 | .hello-title{ 2 | color: darkgreen; 3 | } -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-hsql/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml 3 | target 4 | *.DS_Store 5 | .mvn 6 | mvn* -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-helloworld/src/main/resources/static/css/main.css: -------------------------------------------------------------------------------- 1 | .hello-title{ 2 | color: darkgreen; 3 | } -------------------------------------------------------------------------------- /springboot-examples/springboot-thymeleaf-helloworld/src/main/resources/static/css/main.css: -------------------------------------------------------------------------------- 1 | .hello-title{ 2 | color: darkgreen; 3 | } -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mongodb-nginx/app/src/main/resources/static/css/main.css: -------------------------------------------------------------------------------- 1 | .hello-title{ 2 | color: darkgreen; 3 | } -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mysql-nginx/app/src/main/resources/static/css/main.css: -------------------------------------------------------------------------------- 1 | .hello-title{ 2 | color: darkgreen; 3 | } -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-shared-primary-key-hsql/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml 3 | target 4 | *.DS_Store 5 | .mvn 6 | mvn* -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-thymeleaf/src/main/webapp/resources/js/main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | console.log("Hello World!"); 3 | })(); -------------------------------------------------------------------------------- /springboot-examples/springboot-email-verification-mysql/src/main/resources/static/css/main.css: -------------------------------------------------------------------------------- 1 | .hello-title{ 2 | color: darkgreen; 3 | } -------------------------------------------------------------------------------- /springboot-examples/springboot-flyway/src/main/resources/db/migration/V1.3__delete_book.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM `book` where `title` = 'Hello Koding 2'; -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-contact/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | out 3 | .settings 4 | .classpath 5 | .project 6 | .idea 7 | *.iml -------------------------------------------------------------------------------- /springboot-examples/springboot-jsp-helloworld/src/main/resources/static/js/main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | console.log("Hello World!"); 3 | })(); -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-nginx/app/src/main/resources/static/js/main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | console.log("Hello World!"); 3 | })(); -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-contact/src/main/resources/static/js/main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | console.log("Hello World!"); 3 | })(); -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-submission/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | out 3 | .settings 4 | .classpath 5 | .project 6 | .idea 7 | *.iml -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-validation/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | out 3 | .settings 4 | .classpath 5 | .project 6 | .idea 7 | *.iml -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-helloworld/src/main/resources/static/js/main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | console.log("Hello World!"); 3 | })(); -------------------------------------------------------------------------------- /springboot-examples/springboot-thymeleaf-helloworld/src/main/resources/static/js/main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | console.log("Hello World!"); 3 | })(); -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mysql-nginx/app/src/main/resources/static/js/main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | console.log("Hello World!"); 3 | })(); -------------------------------------------------------------------------------- /springboot-examples/springboot-crud-mysql-vuejs/src/main/resources/static/products.css: -------------------------------------------------------------------------------- 1 | .actions { 2 | margin-bottom: 20px; 3 | margin-top: 20px; 4 | } -------------------------------------------------------------------------------- /springboot-examples/springboot-email-verification-mysql/src/main/resources/static/js/main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | console.log("Hello World!"); 3 | })(); -------------------------------------------------------------------------------- /springboot-examples/springboot-nested-properties-file/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | simple.a=Simple property 2 | nested.a.b=Nested property -------------------------------------------------------------------------------- /springboot-examples/springboot-security-login-thymeleaf/src/main/resources/static/js/main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | console.log("Hello World!"); 3 | })(); -------------------------------------------------------------------------------- /springboot-examples/springboot-single-sign-on-jwt/resources-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | services.auth=http://localhost:8080/login -------------------------------------------------------------------------------- /springboot-examples/springboot-uploading-files/.gitignore: -------------------------------------------------------------------------------- 1 | uploadingDir 2 | target 3 | out 4 | .settings 5 | .classpath 6 | .project 7 | .idea 8 | *.iml -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mongodb-nginx/app/src/main/resources/static/js/main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | console.log("Hello World!"); 3 | })(); -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-submission/src/main/resources/static/js/main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | console.log("Hello FreeMarker Form!"); 3 | })(); -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-validation/src/main/resources/static/js/main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | console.log("Hello FreeMaker Form!"); 3 | })(); -------------------------------------------------------------------------------- /springboot-examples/springboot-jsp-helloworld/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.mvc.view.prefix: /WEB-INF/jsp/ 2 | spring.mvc.view.suffix: .jsp 3 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-hsql/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jpa.hibernate.ddl-auto=create-drop 2 | spring.jpa.show-sql=true -------------------------------------------------------------------------------- /springboot-examples/springboot-uploading-files/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.freemarker.template-loader-path: / 2 | spring.freemarker.suffix: .ftl -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-crud-deleting-entity/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jpa.hibernate.ddl-auto=create-drop 2 | spring.jpa.show-sql=true -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-contact/src/main/resources/static/css/main.css: -------------------------------------------------------------------------------- 1 | h2 { 2 | color: darkgreen; 3 | } 4 | 5 | form b { 6 | color: red; 7 | } -------------------------------------------------------------------------------- /springboot-examples/springboot-single-sign-on-jwt/auth-service/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | out 3 | .settings 4 | .classpath 5 | .project 6 | .idea 7 | *.iml 8 | *.DS_Store 9 | -------------------------------------------------------------------------------- /springboot-examples/springboot-single-sign-out-jwt/auth-service/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | out 3 | .settings 4 | .classpath 5 | .project 6 | .idea 7 | *.iml 8 | *.DS_Store 9 | -------------------------------------------------------------------------------- /springboot-examples/springboot-single-sign-out-jwt/resources-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | services.auth=http://localhost:8080/login 2 | server.port=8180 -------------------------------------------------------------------------------- /springboot-examples/springboot-single-sign-on-jwt/resources-service/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | out 3 | .settings 4 | .classpath 5 | .project 6 | .idea 7 | *.iml 8 | *.DS_Store 9 | -------------------------------------------------------------------------------- /springboot-examples/springboot-single-sign-out-jwt/resources-service/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | out 3 | .settings 4 | .classpath 5 | .project 6 | .idea 7 | *.iml 8 | *.DS_Store 9 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-shared-primary-key-hsql/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jpa.hibernate.ddl-auto=create-drop 2 | spring.jpa.show-sql=true -------------------------------------------------------------------------------- /springboot-examples/lombok-example/src/main/java/com/hellokoding/springboot/product/Main.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.product; 2 | 3 | public class Main { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-validation/src/main/resources/static/css/main.css: -------------------------------------------------------------------------------- 1 | body * { 2 | font-weight: 400; 3 | } 4 | 5 | form b { 6 | color: red; 7 | } 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | target 3 | *.iml 4 | .project 5 | .settings 6 | .DS_Store 7 | .classpath 8 | .factorypath 9 | dump.rdb 10 | Test.java 11 | *.log 12 | config 13 | .env 14 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-nginx/app/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.freemarker.template-loader-path: classpath:/templates 2 | spring.freemarker.suffix: .ftl -------------------------------------------------------------------------------- /springboot-examples/springboot-flyway/src/main/resources/db/migration/V1.1__insert_book.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO `book`(`title`, `description`) VALUES('Hello Koding', 'Coding tutorials series'); -------------------------------------------------------------------------------- /springboot-examples/springboot-flyway/src/main/resources/db/migration/V1.2__insert_book.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO `book`(`title`, `description`) VALUES('Hello Koding 2', 'Coding tutorials series 2'); -------------------------------------------------------------------------------- /spring-examples/spring-webflux/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellokoding/hellokoding-courses/HEAD/spring-examples/spring-webflux/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-helloworld/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.freemarker.template-loader-path: classpath:/templates 2 | spring.freemarker.suffix: .ftlh -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-submission/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.freemarker.template-loader-path: classpath:/templates 2 | spring.freemarker.suffix: .ftlh -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-validation/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.freemarker.template-loader-path: classpath:/templates 2 | spring.freemarker.suffix: .ftlh -------------------------------------------------------------------------------- /springboot-examples/springboot-mockmvc-hsql/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jpa.hibernate.ddl-auto=create-drop 2 | spring.jpa.show-sql=true 3 | 4 | spring.freemarker.suffix=.html -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi-validation/src/main/resources/ValidationMessages.properties: -------------------------------------------------------------------------------- 1 | NotNull.name=Name is required 2 | ProductIDExisting=Product ID ${validatedValue} is not existing -------------------------------------------------------------------------------- /springboot-examples/springboot-actuator/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellokoding/hellokoding-courses/HEAD/springboot-examples/springboot-actuator/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi-testing-all-layers/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jpa.hibernate.ddl-auto=create-drop 2 | spring.jpa.generate-ddl=true 3 | spring.jpa.show-sql=true 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HelloKoding - Practical Coding Guides 2 | 3 | HelloKoding provides practical coding guides series of Spring Boot, Java, Algorithms and other topics on software engineering 4 | 5 | https://hellokoding.com 6 | -------------------------------------------------------------------------------- /springboot-examples/springboot-actuator/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | management.endpoints.web.exposure.include=* 2 | management.endpoint.health.show-details=always 3 | management.health.diskspace.enabled=false -------------------------------------------------------------------------------- /springboot-examples/springboot-thymeleaf-helloworld/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.thymeleaf.template-loader-path: classpath:/templates 2 | spring.thymeleaf.suffix: .html 3 | spring.thymeleaf.cache: false -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-submission/src/main/resources/static/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | width: 50%; 3 | margin-left: auto; 4 | margin-right: auto; 5 | } 6 | 7 | body * { 8 | font-weight: 400; 9 | } -------------------------------------------------------------------------------- /datastructure-algorithm-java-examples/src/main/java/com/hellokoding/algorithm/LongestSubstringWithoutRepeatingCharsWS.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.algorithm; 2 | 3 | public class LongestSubstringWithoutRepeatingCharsWS { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mongodb-nginx/app/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.freemarker.template-loader-path: classpath:/templates 2 | spring.freemarker.suffix: .ftl 3 | 4 | spring.data.mongodb.host=hk-mongodb -------------------------------------------------------------------------------- /springboot-examples/springboot-security-login-thymeleaf/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellokoding/hellokoding-courses/HEAD/springboot-examples/springboot-security-login-thymeleaf/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jpa-hibernate-examples/springboot-mapstruct-onetomany/src/main/java/com/hellokoding/springboot/LibraryMapper.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot; 2 | 3 | import org.mapstruct.Mapper; 4 | 5 | @Mapper 6 | public class LibraryMapper { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-contact/src/main/java/com/hellokoding/form/service/SendingMailService.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.form.service; 2 | 3 | public interface SendingMailService { 4 | boolean sendMail(String subject, String body); 5 | } 6 | -------------------------------------------------------------------------------- /java-examples/java-properties-file/src/main/java/com/hellokoding/util/Main.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.util; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println(ApplicationProperties.INSTANCE.getAppName()); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /spring-examples/spring-webflux/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /springboot-examples/springboot-flyway/src/main/java/com/hellokoding/springboot/jpa/book/Product.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.jpa.book; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class Product { 7 | private Integer id; 8 | private String name; 9 | } 10 | -------------------------------------------------------------------------------- /java-examples/java-core/src/test/java/com/hellokoding/java/lang/BookWithoutEquals.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.java.lang; 2 | 3 | public class BookWithoutEquals { 4 | String title; 5 | 6 | public BookWithoutEquals(String title) { 7 | this.title = title; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /springboot-examples/springboot-actuator/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.2/apache-maven-3.6.2-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar 3 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-mysql/src/main/java/com/hellokoding/jpa/book/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface BookRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /springboot-examples/springboot-registration-login/src/main/java/com/hellokoding/auth/service/SecurityService.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.auth.service; 2 | 3 | public interface SecurityService { 4 | String findLoggedInUsername(); 5 | 6 | void autoLogin(String username, String password); 7 | } 8 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/springboot-mapstruct-onetomany/src/main/java/com/hellokoding/springboot/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface BookRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /springboot-examples/springboot-flyway/src/main/java/com/hellokoding/springboot/jpa/book/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface BookRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-circular-reference-jackson/src/main/java/com/hellokoding/jpa/book/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface BookRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /springboot-examples/springboot-mockmvc-hsql/src/main/java/com/hellokoding/springboot/restful/StockRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface StockRepository extends JpaRepository { 6 | } 7 | -------------------------------------------------------------------------------- /springboot-examples/springboot-security-login-thymeleaf/src/main/java/com/hellokoding/tutorials/service/SecurityService.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.tutorials.service; 2 | 3 | public interface SecurityService { 4 | boolean isAuthenticated(); 5 | void autoLogin(String username, String password); 6 | } 7 | -------------------------------------------------------------------------------- /java-examples/java-core/src/test/java/com/hellokoding/java/collections/NonComparableBook.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.java.collections; 2 | 3 | public class NonComparableBook { 4 | public String title; 5 | 6 | public NonComparableBook(String title) { 7 | this.title = title; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-circular-reference-jackson/src/main/java/com/hellokoding/jpa/book/AuthorRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface AuthorRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-composite-primary-key-mysql/src/main/java/com/hellokoding/jpa/EmployeeRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface EmployeeRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-crud-deleting-entity/src/main/java/com/hellokoding/jpa/book/CategoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface CategoryRepository extends JpaRepository { 6 | } 7 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-crud-querying-entity/src/main/java/com/hellokoding/jpa/book/CategoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface CategoryRepository extends JpaRepository { 6 | } 7 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-mysql/src/main/java/com/hellokoding/jpa/book/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface BookRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-mysql/src/main/java/com/hellokoding/jpa/book/PublisherRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface PublisherRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/springboot-mapstruct-onetomany/src/main/java/com/hellokoding/springboot/LibraryRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface LibraryRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /springboot-examples/springboot-security-login-thymeleaf/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-nginx/app/src/main/resources/templates/index.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello Docker and Spring Boot! 6 | 7 | 8 |

Hello Docker and Spring Boot!

9 | 10 | -------------------------------------------------------------------------------- /java-examples/java-app-healthcheck-prometheus/prometheus.yml: -------------------------------------------------------------------------------- 1 | global: 2 | scrape_interval: 15s 3 | evaluation_interval: 15s 4 | 5 | scrape_configs: 6 | - job_name: prometheus 7 | static_configs: 8 | - targets: ['localhost:9090'] 9 | 10 | - job_name: app 11 | static_configs: 12 | - targets: ['app:8080'] -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-mysql-rest/src/main/java/com/hellokoding/jpa/book/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface BookRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /springboot-examples/springboot-flyway/src/main/resources/db/migration/V1.0__create_book.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `book` ( 2 | `id` int(11) NOT NULL AUTO_INCREMENT, 3 | `description` varchar(255) DEFAULT NULL, 4 | `title` varchar(255) DEFAULT NULL, 5 | PRIMARY KEY (`id`) 6 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-circular-reference-jackson/src/main/java/com/hellokoding/jpa/book/CategoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface CategoryRepository extends JpaRepository { 6 | } 7 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-circular-reference-jackson/src/main/java/com/hellokoding/jpa/book/PublisherRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface PublisherRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-mysql-rest/src/main/java/com/hellokoding/jpa/bidirectional/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.bidirectional; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface BookRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-mysql/src/main/java/com/hellokoding/jpa/book/BookCategoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface BookCategoryRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /spring-mvc-examples/registration-login-spring-xml-maven-jsp-mysql/src/main/java/com/hellokoding/account/service/SecurityService.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.account.service; 2 | 3 | public interface SecurityService { 4 | String findLoggedInUsername(); 5 | 6 | void autologin(String username, String password); 7 | } 8 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-mysql/src/main/java/com/hellokoding/jpa/book/PublisherRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface PublisherRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /springboot-examples/springboot-mapstruct/src/main/java/com/hellokoding/springboot/restful/product/ProductRespository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful.product; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface ProductRespository extends JpaRepository { 6 | } 7 | -------------------------------------------------------------------------------- /springboot-examples/springboot-registration-login/src/main/java/com/hellokoding/auth/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.auth.service; 2 | 3 | import com.hellokoding.auth.model.User; 4 | 5 | public interface UserService { 6 | void save(User user); 7 | 8 | User findByUsername(String username); 9 | } 10 | -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi/src/main/java/com/hellokoding/springboot/restful/product/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful.product; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface ProductRepository extends JpaRepository { 6 | } 7 | -------------------------------------------------------------------------------- /springboot-examples/springboot-swagger/src/main/java/com/hellokoding/springboot/restful/product/ProductRespository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful.product; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface ProductRespository extends JpaRepository { 6 | } 7 | -------------------------------------------------------------------------------- /springboot-examples/springboot-todomvc-mysql-vuejs/src/main/java/com/hellokoding/springboot/fullstack/todo/TodoRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.fullstack.todo; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface TodoRepository extends JpaRepository { 6 | } 7 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-circular-reference-jackson/src/main/java/com/hellokoding/jpa/book/BookPublisherRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface BookPublisherRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-mysql-rest/src/main/java/com/hellokoding/jpa/book/PublisherRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface PublisherRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-mysql-rest/src/main/java/com/hellokoding/jpa/bidirectional/LibraryRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.bidirectional; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface LibraryRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-mysql-rest/src/main/java/com/hellokoding/jpa/unidirectional/LibraryRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.unidirectional; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface LibraryRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /spring-mvc-examples/registration-login-spring-xml-maven-jsp-mysql/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | jdbc.driverClassName=com.mysql.jdbc.Driver 2 | jdbc.url=jdbc:mysql://localhost:3306/accounts?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull 3 | jdbc.username=hellokoding 4 | jdbc.password=hellokoding 5 | -------------------------------------------------------------------------------- /springboot-examples/springboot-caching-redis/src/main/java/com/hellokoding/springboot/caching/product/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.caching.product; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface ProductRepository extends JpaRepository { 6 | } 7 | -------------------------------------------------------------------------------- /springboot-examples/springboot-crud-mysql-vuejs/src/main/java/com/hellokoding/springboot/restful/product/ProductRespository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful.product; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface ProductRespository extends JpaRepository { 6 | } 7 | -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi-validation/src/main/java/com/hellokoding/springboot/restful/product/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful.product; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface ProductRepository extends JpaRepository { 6 | } 7 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/springboot-mapstruct-onetomany/src/main/java/com/hellokoding/springboot/unidirectional/LibraryRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.unidirectional; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface LibraryRepository extends JpaRepository{ 6 | } 7 | -------------------------------------------------------------------------------- /springboot-examples/springboot-registration-login/src/main/java/com/hellokoding/auth/repository/RoleRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.auth.repository; 2 | 3 | import com.hellokoding.auth.model.Role; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface RoleRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /springboot-examples/springboot-security-login-thymeleaf/src/main/java/com/hellokoding/tutorials/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.tutorials.service; 2 | 3 | import com.hellokoding.tutorials.model.User; 4 | 5 | public interface UserService { 6 | void save(User user); 7 | 8 | User findByUsername(String username); 9 | } 10 | -------------------------------------------------------------------------------- /springboot-examples/springboot-security-login-thymeleaf/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jpa.hibernate.ddl-auto=create-drop 2 | spring.jpa.show-sql=true 3 | 4 | spring.thymeleaf.template-loader-path: classpath:/templates 5 | spring.thymeleaf.suffix: .html 6 | spring.thymeleaf.cache: false 7 | 8 | spring.messages.basename=validation 9 | -------------------------------------------------------------------------------- /springboot-examples/springboot-single-sign-on-jwt/resources-service/src/main/resources/templates/protected-resource.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Protected Resource Service 5 | 6 | 7 |

Hello, ${Request.username!}

8 | Logout 9 | 10 | -------------------------------------------------------------------------------- /springboot-examples/springboot-single-sign-out-jwt/resources-service/src/main/resources/templates/protected-resource.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Protected Resource Service 5 | 6 | 7 |

Hello, ${Request.username!}

8 | Logout 9 | 10 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-hsql/src/main/java/com/hellokoding/jpa/repository/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.repository; 2 | 3 | import com.hellokoding.jpa.model.Book; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface BookRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /spring-mvc-examples/registration-login-spring-xml-maven-jsp-mysql/src/main/java/com/hellokoding/account/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.account.service; 2 | 3 | import com.hellokoding.account.model.User; 4 | 5 | public interface UserService { 6 | void save(User user); 7 | 8 | User findByUsername(String username); 9 | } 10 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-hsql/src/main/java/com/hellokoding/jpa/repository/IDCardRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.repository; 2 | 3 | import com.hellokoding.jpa.model.IDCard; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface IDCardRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-hsql/src/main/java/com/hellokoding/jpa/repository/PersonRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.repository; 2 | 3 | import com.hellokoding.jpa.model.Person; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface PersonRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /java-examples/java-bean-validation/src/main/resources/ValidationMessages.properties: -------------------------------------------------------------------------------- 1 | javax.validation.constraints.NotNull.message=is required 2 | Size.name=must be between {min} and {max} character long 3 | ProductCodeExisting="${validatedValue}" is not existing 4 | Min.price=${formatter.format('%1$.2f', validatedValue)} is invalid, must be greater than or equal to {value} -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-mysql/src/main/java/com/hellokoding/jpa/repository/PersonRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.repository; 2 | 3 | import com.hellokoding.jpa.model.Person; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface PersonRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /spring-examples/spring-webflux/src/test/java/com/hellokoding/spring/HelloApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.spring; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class HelloApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-hsql/src/main/java/com/hellokoding/jpa/repository/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.repository; 2 | 3 | import com.hellokoding.jpa.model.Book; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface BookRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /springboot-examples/springboot-security-login-thymeleaf/src/main/java/com/hellokoding/tutorials/repository/RoleRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.tutorials.repository; 2 | 3 | import com.hellokoding.tutorials.model.Role; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface RoleRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mysql-nginx/app/src/main/resources/templates/index.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Docker Compose with Spring Boot, MySQL, NGINX 6 | 7 | 8 |

Docker Compose with Spring Boot, MySQL, NGINX

9 |

10 | 11 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-hsql/src/main/java/com/hellokoding/jpa/repository/PublisherRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.repository; 2 | 3 | import com.hellokoding.jpa.model.Publisher; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface PublisherRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-shared-primary-key-hsql/src/main/java/com/hellokoding/jpa/repository/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.repository; 2 | 3 | import com.hellokoding.jpa.model.Book; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface BookRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /spring-mvc-examples/registration-login-spring-xml-maven-jsp-mysql/src/main/java/com/hellokoding/account/repository/RoleRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.account.repository; 2 | 3 | import com.hellokoding.account.model.Role; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface RoleRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /springboot-examples/springboot-registration-login/src/main/resources/validation.properties: -------------------------------------------------------------------------------- 1 | NotEmpty=This field is required. 2 | Size.userForm.username=Please use between 6 and 32 characters. 3 | Duplicate.userForm.username=Someone already has that username. 4 | Size.userForm.password=Try one with at least 8 characters. 5 | Diff.userForm.passwordConfirm=These passwords don't match. -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-many-to-many/src/main/java/com/hellokoding/restfulapi/repository/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.restfulapi.repository; 2 | 3 | import com.hellokoding.restfulapi.model.Book; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface BookRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-one-to-many/src/main/java/com/hellokoding/restfulapi/repository/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.restfulapi.repository; 2 | 3 | import com.hellokoding.restfulapi.model.Book; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface BookRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mongodb-nginx/app/src/main/resources/templates/index.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Docker Compose with Spring Boot, MongoDB, NGINX 6 | 7 | 8 |

Docker Compose with Spring Boot, MongoDB, NGINX

9 |

10 | 11 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-shared-primary-key-mysql/src/main/java/com/hellokoding/jpa/repository/PersonRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.repository; 2 | 3 | import com.hellokoding.jpa.model.Person; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface PersonRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /springboot-examples/springboot-security-login-thymeleaf/src/main/resources/validation.properties: -------------------------------------------------------------------------------- 1 | NotEmpty=This field is required. 2 | Size.userForm.username=Please use between 6 and 32 characters. 3 | Duplicate.userForm.username=Someone already has that username. 4 | Size.userForm.password=Try one with at least 8 characters. 5 | Diff.userForm.passwordConfirm=These passwords don't match. -------------------------------------------------------------------------------- /java-examples/java-jooq-mysql/create_db.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE `library`; 2 | 3 | USE `library`; 4 | 5 | CREATE TABLE `author` ( 6 | `id` int NOT NULL, 7 | `first_name` varchar(255) DEFAULT NULL, 8 | `last_name` varchar(255) DEFAULT NULL, 9 | PRIMARY KEY (`id`) 10 | ); 11 | 12 | INSERT INTO author(1, 'Hello', 'Koding'); 13 | INSERT INTO author(2, 'jOOQ', 'Example'); 14 | -------------------------------------------------------------------------------- /springboot-examples/springboot-email-verification-mysql/src/main/resources/templates/email-verification.ftl: -------------------------------------------------------------------------------- 1 | Hi Giau,
2 | 3 | Thanks for using Hello Koding! Please confirm your email address by clicking on the link below.
4 | 5 | ${VERIFICATION_URL}
6 | 7 | If you did not sign up for a Hello Koding account please disregard this email.
8 | 9 | The Hello Koding team, -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-many-to-many/src/main/java/com/hellokoding/restfulapi/repository/AuthorRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.restfulapi.repository; 2 | 3 | import com.hellokoding.restfulapi.model.Author; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface AuthorRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-hsql/src/main/java/com/hellokoding/jpa/repository/PublisherRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.repository; 2 | 3 | import com.hellokoding.jpa.model.Publisher; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface PublisherRepository extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /spring-mvc-examples/registration-login-spring-xml-maven-jsp-mysql/src/main/resources/validation.properties: -------------------------------------------------------------------------------- 1 | NotEmpty=This field is required. 2 | Size.userForm.username=Please use between 6 and 32 characters. 3 | Duplicate.userForm.username=Someone already has that username. 4 | Size.userForm.password=Try one with at least 8 characters. 5 | Diff.userForm.passwordConfirm=These passwords don't match. -------------------------------------------------------------------------------- /springboot-examples/springboot-swagger/src/main/java/com/hellokoding/springboot/restful/product/ProductDTO.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful.product; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | 7 | @Data 8 | public class ProductDTO { 9 | private String name; 10 | private String description; 11 | private BigDecimal price; 12 | } 13 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-many-to-many-extra-columns/src/main/java/com/hellokoding/restfulapi/repository/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.restfulapi.repository; 2 | 3 | import com.hellokoding.restfulapi.model.Book; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface BookRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-hsql/src/main/java/com/hellokoding/jpa/repository/BookPublisherRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.repository; 2 | 3 | import com.hellokoding.jpa.model.BookPublisher; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface BookPublisherRepository extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /springboot-examples/springboot-mapstruct/src/main/java/com/hellokoding/springboot/restful/product/ProductDTO.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful.product; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | 7 | @Data 8 | public class ProductDTO { 9 | private String name; 10 | private String description; 11 | private BigDecimal price; 12 | } 13 | -------------------------------------------------------------------------------- /springboot-examples/springboot-security-login-thymeleaf/src/test/java/com/hellokoding/tutorials/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.tutorials; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class DemoApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /springboot-examples/springboot-jsp-helloworld/src/main/webapp/WEB-INF/jsp/hello.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello ${name}! 6 | 7 | 8 | 9 |

Hello ${name}!

10 | 11 | 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-registration-login/src/main/java/com/hellokoding/auth/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.auth.repository; 2 | 3 | import com.hellokoding.auth.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface UserRepository extends JpaRepository { 7 | User findByUsername(String username); 8 | } 9 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-one-to-many/src/main/java/com/hellokoding/restfulapi/repository/BookCategoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.restfulapi.repository; 2 | 3 | import com.hellokoding.restfulapi.model.BookCategory; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface BookCategoryRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-deleting-data/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false&allowPublicKeyRetrieval=true 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | 5 | spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.show-sql=true 8 | -------------------------------------------------------------------------------- /springboot-examples/springboot-actuator/src/test/java/com/hellokoding/springboot/SpringbootActuatorApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringbootActuatorApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-helloworld/src/main/resources/templates/hello.ftlh: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello ${name}! 6 | 7 | 8 | 9 |

Hello ${name}!

10 | 11 | 12 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-many-to-many-extra-columns/src/main/java/com/hellokoding/restfulapi/repository/PublisherRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.restfulapi.repository; 2 | 3 | import com.hellokoding.restfulapi.model.Publisher; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface PublisherRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/springboot-mapstruct-onetomany/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false&allowPublicKeyRetrieval=true 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | 5 | spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.show-sql=true 8 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-mysql-rest/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false&allowPublicKeyRetrieval=true 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | 5 | spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.show-sql=true 8 | -------------------------------------------------------------------------------- /springboot-examples/springboot-security-login-thymeleaf/src/main/java/com/hellokoding/tutorials/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.tutorials.repository; 2 | 3 | import com.hellokoding.tutorials.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface UserRepository extends JpaRepository { 7 | User findByUsername(String username); 8 | } 9 | -------------------------------------------------------------------------------- /spring-mvc-examples/registration-login-spring-xml-maven-jsp-mysql/src/main/java/com/hellokoding/account/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.account.repository; 2 | 3 | import com.hellokoding.account.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface UserRepository extends JpaRepository { 7 | User findByUsername(String username); 8 | } 9 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-many-to-many-extra-columns/src/main/java/com/hellokoding/restfulapi/repository/BookPublisherRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.restfulapi.repository; 2 | 3 | import com.hellokoding.restfulapi.model.BookPublisher; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface BookPublisherRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-single/src/main/java/com/hellokoding/springdatarest/book/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springdatarest.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 5 | 6 | @RepositoryRestResource 7 | public interface BookRepository extends JpaRepository{ 8 | } 9 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-composite-primary-key-mysql/src/main/java/com/hellokoding/jpa/EmployeePhoneId.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class EmployeePhoneId implements Serializable { 9 | private Employee employee; 10 | private String phone; 11 | 12 | public EmployeePhoneId() { 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi-validation/src/main/java/com/hellokoding/springboot/restful/ResponseDTO.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | @Data 7 | @Builder 8 | public class ResponseDTO { 9 | private String status; 10 | 11 | @Builder.Default 12 | private String message = "Success!"; 13 | 14 | private T body; 15 | } 16 | -------------------------------------------------------------------------------- /spring-examples/spring-aop-example/src/main/java/com/hellokoding/spring/LogExecutionTime.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.spring; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.METHOD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface LogExecutionTime { 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/lombok-example/src/main/java/com/hellokoding/springboot/product/Product.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.product; 2 | 3 | import lombok.*; 4 | import lombok.extern.slf4j.Slf4j; 5 | 6 | 7 | @Getter 8 | @Setter 9 | @ToString 10 | @EqualsAndHashCode 11 | @Slf4j 12 | public class Product { 13 | private Integer id; 14 | private String name; 15 | 16 | static void main() { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi-testing-all-layers/src/main/java/com/hellokoding/springboot/restful/product/ProductRespository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful.product; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import java.util.Optional; 6 | 7 | public interface ProductRespository extends JpaRepository { 8 | Optional findByName(String name); 9 | } 10 | -------------------------------------------------------------------------------- /spring-examples/spring-webflux/src/main/java/com/hellokoding/spring/HelloApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.spring; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class HelloApplication { 8 | public static void main(String[] args) { 9 | SpringApplication.run(HelloApplication.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-mockmvc-hsql/src/main/java/com/hellokoding/springboot/restful/StockController.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | 6 | @Controller 7 | public class StockController { 8 | @GetMapping("/") 9 | public String list(){ 10 | return "stocklist"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datastructure-algorithm-java-examples/src/main/java/com/hellokoding/algorithm/FibonacciRecursion.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.algorithm; 2 | 3 | public class FibonacciRecursion { 4 | int fibonacci(int i) { 5 | if (i < 2) return i; 6 | return fibonacci(i-1) + fibonacci(i-2); 7 | } 8 | 9 | public static void main(String[] args) { 10 | System.out.println(new FibonacciRecursion().fibonacci(10)); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-mysql-rest/src/main/java/com/hellokoding/jpa/book/BookPublisherRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import java.util.List; 6 | 7 | public interface BookPublisherRepository extends JpaRepository{ 8 | List findByPublisherId(Integer publisherId); 9 | } 10 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-problems/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false&allowPublicKeyRetrieval=true 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | 5 | spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.show-sql=true 8 | spring.jpa.properties.hibernate.generate_statistics=true -------------------------------------------------------------------------------- /spring-examples/spring-aop-example/src/test/java/com/hellokoding/spring/Foo.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.spring; 2 | 3 | public class Foo { 4 | public String fooBar() { 5 | return "foo" + this.bar(); 6 | } 7 | 8 | private String fooPrivate() { 9 | return "foo"; 10 | } 11 | 12 | private String bar() { 13 | return "bar"; 14 | } 15 | } 16 | 17 | interface FooInterface { 18 | String foo(); 19 | } 20 | -------------------------------------------------------------------------------- /springboot-examples/springboot-email-verification-mysql/src/main/java/com/hellokoding/account/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.account.repository; 2 | 3 | import com.hellokoding.account.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | import java.util.List; 7 | 8 | public interface UserRepository extends JpaRepository { 9 | List findByEmail(String email); 10 | } 11 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-hsql/src/main/java/com/hellokoding/jpa/repository/BookCategoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.repository; 2 | 3 | import com.hellokoding.jpa.model.BookCategory; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface BookCategoryRepository extends JpaRepository{ 9 | } 10 | -------------------------------------------------------------------------------- /springboot-examples/springboot-todomvc-mysql-vuejs/src/main/java/com/hellokoding/springboot/fullstack/todo/TodoController.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.fullstack.todo; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | 6 | @Controller 7 | public class TodoController { 8 | @GetMapping("/") 9 | public String list(){ 10 | return "todo"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-single/src/main/java/com/hellokoding/springdatarest/book/Book.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springdatarest.book; 2 | 3 | import lombok.*; 4 | 5 | import javax.persistence.*; 6 | 7 | @Entity 8 | 9 | @Data 10 | public class Book { 11 | @Id 12 | @GeneratedValue(strategy = GenerationType.IDENTITY) 13 | private int id; 14 | 15 | private String title; 16 | 17 | private String description; 18 | } 19 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-hsql/src/main/java/com/hellokoding/jpa/repository/BookPublisherRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.repository; 2 | 3 | import com.hellokoding.jpa.model.BookPublisher; 4 | import com.hellokoding.jpa.model.BookPublisherId; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | public interface BookPublisherRepository extends JpaRepository { 8 | } 9 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-mysql/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false&allowPublicKeyRetrieval=true 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | 5 | spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.show-sql=true 8 | spring.jpa.properties.hibernate.generate_statistics=true -------------------------------------------------------------------------------- /springboot-examples/springboot-crud-mysql-vuejs/src/main/java/com/hellokoding/springboot/restful/product/ProductController.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful.product; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | 6 | @Controller 7 | public class ProductController { 8 | @GetMapping("/") 9 | public String list(){ 10 | return "products"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-contact/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.freemarker.template-loader-path: classpath:/templates 2 | spring.freemarker.suffix: .ftl 3 | 4 | mail.smtp.host={YOUR_SES_SMTP_HOST} 5 | mail.smtp.port={YOUR_SES_SMTP_PORT} 6 | mail.smtp.username={YOUR_SES_SMTP_USERNAME} 7 | mail.smtp.password={YOUR_SES_SMTP_PASSWORD} 8 | mail.from={YOUR_FROM_EMAIL} 9 | mail.from-name={YOUR_FROM_NAME} 10 | mail.to={YOUR_TO_EMAIL} -------------------------------------------------------------------------------- /datastructure-algorithm-java-examples/src/main/java/com/hellokoding/datastructure/Array1D.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.datastructure; 2 | 3 | public class Array1D { 4 | void traversal(int[] A) { 5 | for (int i = 0; i < A.length; i++) { 6 | System.out.println(A[i]); 7 | } 8 | } 9 | 10 | public static void main(String[] args) { 11 | int[] A = {9, 2, 6, 8}; 12 | new Array1D().traversal(A); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /java-examples/java-core/src/test/java/com/hellokoding/java/collections/ComparableBook.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.java.collections; 2 | 3 | public class ComparableBook implements Comparable { 4 | String title; 5 | 6 | public ComparableBook(String title) { 7 | this.title = title; 8 | } 9 | 10 | @Override 11 | public int compareTo(ComparableBook o) { 12 | return this.title.compareTo(o.title); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /java-examples/java-core/src/test/java/com/hellokoding/java/java14/HelpfulNullPointerException.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.java.java14; 2 | 3 | import org.junit.Test; 4 | 5 | public class HelpfulNullPointerException { 6 | public void nullString(Pojo pojo) { 7 | pojo.field1 = "a"; 8 | } 9 | 10 | @Test 11 | public void testNullString() { 12 | nullString(null); 13 | } 14 | } 15 | 16 | class Pojo { 17 | String field1; 18 | } 19 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-crud-deleting-entity/src/main/java/com/hellokoding/jpa/JpaApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class JpaApplication { 8 | public static void main(String[] args) { 9 | SpringApplication.run(JpaApplication.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-mapstruct/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://hk-mysql:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | -------------------------------------------------------------------------------- /springboot-examples/springboot-swagger/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://hk-mysql:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-one-to-many/src/main/java/com/hellokoding/restfulapi/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.restfulapi; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/springboot-mapstruct-onetomany/src/main/java/com/hellokoding/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-jsp-helloworld/src/main/java/com/hellokoding/springboot/view/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.view; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-mapstruct/src/main/java/com/hellokoding/springboot/restful/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi/src/main/java/com/hellokoding/springboot/restful/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-many-to-many/src/main/java/com/hellokoding/restfulapi/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.restfulapi; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-single/src/main/java/com/hellokoding/springdatarest/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springdatarest; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-circular-reference-jackson/src/main/java/com/hellokoding/jpa/JpaApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class JpaApplication { 8 | public static void main(String[] args) { 9 | SpringApplication.run(JpaApplication.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-contact/src/main/java/com/hellokoding/form/WebApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.form; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class WebApplication { 8 | public static void main(String[] args) throws Exception { 9 | SpringApplication.run(WebApplication.class, args); 10 | } 11 | } -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-helloworld/src/main/java/com/hellokoding/springboot/view/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.view; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-mapstruct/src/main/java/com/hellokoding/springboot/restful/product/ProductMapper.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful.product; 2 | 3 | import org.mapstruct.Mapper; 4 | 5 | import java.util.List; 6 | 7 | @Mapper 8 | public interface ProductMapper { 9 | ProductDTO toProductDTO(Product product); 10 | 11 | List toProductDTOs(List products); 12 | 13 | Product toProduct(ProductDTO productDTO); 14 | } 15 | -------------------------------------------------------------------------------- /springboot-examples/springboot-mockmvc-hsql/src/main/java/com/hellokoding/springboot/restful/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application{ 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-swagger/src/main/java/com/hellokoding/springboot/restful/product/ProductMapper.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful.product; 2 | 3 | import org.mapstruct.Mapper; 4 | 5 | import java.util.List; 6 | 7 | @Mapper 8 | public interface ProductMapper { 9 | ProductDTO toProductDTO(Product product); 10 | 11 | List toProductDTOs(List products); 12 | 13 | Product toProduct(ProductDTO productDTO); 14 | } 15 | -------------------------------------------------------------------------------- /springboot-examples/springboot-thymeleaf-helloworld/src/main/java/com/hellokoding/springboot/view/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.view; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-single/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://hk-mysql:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-hsql/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-mysql/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-hsql/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | -------------------------------------------------------------------------------- /springboot-examples/springboot-crud-mysql-vuejs/src/main/java/com/hellokoding/springboot/restful/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-security-login-thymeleaf/src/main/java/com/hellokoding/tutorials/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.tutorials; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DemoApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DemoApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /springboot-examples/springboot-thymeleaf-helloworld/src/main/resources/templates/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |

10 | 11 | 12 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-many-to-many-extra-columns/src/main/java/com/hellokoding/restfulapi/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.restfulapi; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mysql-nginx/app/src/main/java/com/hellokoding/springboot/WebApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class WebApplication { 8 | public static void main(String[] args) { 9 | SpringApplication.run(WebApplication.class, args); 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-crud-querying-entity/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://hk-mysql:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-mysql-rest/src/main/java/com/hellokoding/jpa/JpaApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class JpaApplication { 8 | public static void main(String[] args) { 9 | SpringApplication.run(JpaApplication.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-mysql/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | -------------------------------------------------------------------------------- /springboot-examples/scribejava-oauth2/src/main/java/com/hellokoding/springboot/oauth2/OAuth2Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.oauth2; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class OAuth2Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(OAuth2Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-email-verification-mysql/src/main/java/com/hellokoding/account/WebApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.account; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class WebApplication { 8 | public static void main(String[] args) throws Exception { 9 | SpringApplication.run(WebApplication.class, args); 10 | } 11 | } -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi-testing-all-layers/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://hk-mysql:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi-validation/src/main/java/com/hellokoding/springboot/restful/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | 7 | @SpringBootApplication 8 | public class Application { 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /springboot-examples/springboot-todomvc-mysql-vuejs/src/main/java/com/hellokoding/springboot/fullstack/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.fullstack; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-composite-primary-key-mysql/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-mysql-rest/src/main/java/com/hellokoding/jpa/bidirectional/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.bidirectional; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-mysql-rest/src/main/java/com/hellokoding/jpa/unidirectional/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.unidirectional; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/spring-security-oauth2/src/main/java/com/hellokoding/springboot/oauth2/OAuth2Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.oauth2; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class OAuth2Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(OAuth2Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi-testing-all-layers/src/main/java/com/hellokoding/springboot/restful/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi-testing-all-layers/src/main/java/com/hellokoding/springboot/restful/product/ProductMapper.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful.product; 2 | 3 | import org.mapstruct.Mapper; 4 | 5 | import java.util.List; 6 | 7 | @Mapper 8 | public interface ProductMapper { 9 | ProductDTO toProductDTO(Product product); 10 | 11 | List toProductDTOs(List products); 12 | 13 | Product toProduct(ProductDTO productDTO); 14 | } 15 | -------------------------------------------------------------------------------- /docker-examples/docker-compose-nginx-jetty-mysql/nginx-site-enabled/default: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name localhost; 4 | location / { 5 | proxy_pass http://127.0.0.1:8080; 6 | proxy_http_version 1.1; 7 | proxy_set_header Upgrade $http_upgrade; 8 | proxy_set_header Connection 'upgrade'; 9 | proxy_set_header Host $host; 10 | proxy_cache_bypass $http_upgrade; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-nginx/app/src/main/java/com/hellokoding/springboot/WebApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class WebApplication { 8 | public static void main(String[] args) throws Exception { 9 | SpringApplication.run(WebApplication.class, args); 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-mysql/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-hsql/src/main/java/com/hellokoding/jpa/model/Publisher.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.model; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.*; 6 | 7 | @Data 8 | @Entity 9 | public class Publisher { 10 | @Id 11 | @GeneratedValue(strategy = GenerationType.IDENTITY) 12 | private int id; 13 | 14 | private String name; 15 | 16 | public Publisher(String name) { 17 | this.name = name; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-hsql/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-mysql-rest/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-shared-primary-key-mysql/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/springboot-mapstruct-onetomany/src/main/java/com/hellokoding/springboot/unidirectional/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.unidirectional; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-submission/src/main/java/com/hellokoding/springboot/WebApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class WebApplication { 8 | public static void main(String[] args) throws Exception { 9 | SpringApplication.run(WebApplication.class, args); 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-validation/src/main/java/com/hellokoding/springboot/WebApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class WebApplication { 8 | public static void main(String[] args) throws Exception { 9 | SpringApplication.run(WebApplication.class, args); 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /springboot-examples/springboot-single-sign-on-jwt/auth-service/src/main/java/com/hellokoding/sso/auth/WebApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.sso.auth; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class WebApplication{ 8 | public static void main(String[] args) throws Exception { 9 | SpringApplication.run(WebApplication.class, args); 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /springboot-examples/springboot-single-sign-out-jwt/auth-service/src/main/java/com/hellokoding/sso/auth/WebApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.sso.auth; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class WebApplication { 8 | public static void main(String[] args) throws Exception { 9 | SpringApplication.run(WebApplication.class, args); 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-hsql/src/main/java/com/hellokoding/jpa/model/Book.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.model; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.*; 6 | 7 | @Data 8 | @Entity 9 | public class Book { 10 | @Id 11 | @GeneratedValue(strategy = GenerationType.IDENTITY) 12 | private int id; 13 | 14 | @Column(name = "name") 15 | private String name; 16 | 17 | public Book(String name) { 18 | this.name = name; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /springboot-examples/springboot-actuator/src/main/java/com/hellokoding/springboot/SpringbootActuatorApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootActuatorApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootActuatorApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-examples/spring-webflux/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /springboot-examples/springboot-crud-mysql-vuejs/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://hk-mysql:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | 11 | spring.freemarker.suffix=.html 12 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-circular-reference-jackson/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | 11 | server.port=8080 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-todomvc-mysql-vuejs/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://hk-mysql:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | 11 | spring.freemarker.suffix=.html 12 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-crud-querying-entity/src/main/java/com/hellokoding/jpa/book/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.domain.Pageable; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | import java.util.List; 7 | 8 | public interface BookRepository extends JpaRepository { 9 | List findByCategoryId(int categoryId); 10 | 11 | List findByCategoryId(int categoryId, Pageable pageable); 12 | } 13 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-hsql/src/main/java/com/hellokoding/jpa/model/Person.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.model; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.persistence.*; 7 | 8 | @Getter @Setter 9 | @Entity 10 | public class Person { 11 | @Id 12 | @GeneratedValue(strategy = GenerationType.IDENTITY) 13 | private int id; 14 | 15 | private String name; 16 | 17 | public Person(String name) { 18 | this.name = name; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /springboot-examples/springboot-actuator/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-many-to-many/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 5 | 6 | spring.datasource.initialization-mode=always 7 | spring.jpa.hibernate.ddl-auto=create-drop 8 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 9 | spring.jpa.generate-ddl=true 10 | spring.jpa.show-sql=true -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-one-to-many/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 5 | 6 | spring.datasource.initialization-mode=always 7 | spring.jpa.hibernate.ddl-auto=create-drop 8 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 9 | spring.jpa.generate-ddl=true 10 | spring.jpa.show-sql=true -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-nginx/app/src/main/java/com/hellokoding/springboot/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @Controller 9 | public class IndexController { 10 | @GetMapping("/") 11 | public String index() { 12 | return "index"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /springboot-examples/springboot-flyway/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://hk-mysql:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=none 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | 11 | management.endpoints.web.exposure.include=info,health,flyway 12 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-nginx/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | nginx: 4 | container_name: some-nginx 5 | image: nginx:1.13 6 | restart: always 7 | ports: 8 | - 80:80 9 | - 443:443 10 | volumes: 11 | - ./nginx/conf.d:/etc/nginx/conf.d 12 | depends_on: 13 | - app 14 | 15 | app: 16 | restart: always 17 | build: ./app 18 | working_dir: /app 19 | volumes: 20 | - ./app:/app 21 | expose: 22 | - "8080" 23 | command: mvn clean spring-boot:run 24 | -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-thymeleaf/src/main/webapp/WEB-INF/views/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |

10 | 11 | 12 | -------------------------------------------------------------------------------- /java-examples/java-core/src/test/java/com/hellokoding/java/concurrent/CompletableFutureGetVsJoinTest.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.java.concurrent; 2 | 3 | import org.junit.Test; 4 | 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | public class CompletableFutureGetVsJoinTest { 8 | @Test 9 | public void handleWithException() { 10 | CompletableFuture completableFuture = CompletableFuture 11 | .supplyAsync(() -> Integer.parseInt("s")) 12 | .thenAcceptAsync(System.out::println); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /springboot-examples/springboot-email-verification-mysql/src/main/java/com/hellokoding/account/model/VerificationForm.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.account.model; 2 | 3 | import javax.validation.constraints.Email; 4 | import javax.validation.constraints.NotEmpty; 5 | 6 | public class VerificationForm { 7 | @NotEmpty 8 | @Email 9 | private String email; 10 | 11 | public String getEmail() { 12 | return email; 13 | } 14 | 15 | public void setEmail(String email) { 16 | this.email = email; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-many-to-many-extra-columns/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 5 | 6 | spring.datasource.initialization-mode=always 7 | spring.jpa.hibernate.ddl-auto=create-drop 8 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 9 | spring.jpa.generate-ddl=true 10 | spring.jpa.show-sql=true 11 | -------------------------------------------------------------------------------- /springboot-examples/springboot-caching-redis/src/main/java/com/hellokoding/springboot/caching/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.caching; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cache.annotation.EnableCaching; 6 | 7 | @SpringBootApplication 8 | @EnableCaching 9 | public class Application { 10 | public static void main(String[] args) { 11 | SpringApplication.run(Application.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /datastructure-algorithm-java-examples/src/main/java/com/hellokoding/datastructure/Array2D.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.datastructure; 2 | 3 | public class Array2D { 4 | void traversal(int[][] A) { 5 | for (int i = 0; i < A.length; i++) { 6 | for (int j = 0; j < A[0].length; j++) { 7 | System.out.println(A[i][j]); 8 | } 9 | } 10 | } 11 | 12 | public static void main(String[] args) { 13 | int[][] A = {{9, 2, 6, 8}, {5, 7, 1, 3}}; 14 | new Array2D().traversal(A); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /java-examples/java-bean-validation/src/main/java/com/hellokoding/validation/ProductCodeExistingValidator.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.validation; 2 | 3 | import javax.validation.ConstraintValidator; 4 | import javax.validation.ConstraintValidatorContext; 5 | 6 | public class ProductCodeExistingValidator implements ConstraintValidator { 7 | @Override 8 | public boolean isValid(String productCode, ConstraintValidatorContext context) { 9 | return productCode.equals("P1") || productCode.equals("P2"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-nested-properties-file/src/main/java/com/hellokoding/util/SimpleProperties.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.util; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "simple") 8 | public class SimpleProperties { 9 | private String a; 10 | 11 | public String getA() { 12 | return a; 13 | } 14 | 15 | public void setA(String a) { 16 | this.a = a; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mysql-nginx/app/src/main/java/com/hellokoding/springboot/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | 8 | @Controller 9 | @RequestMapping("/") 10 | public class IndexController { 11 | @GetMapping 12 | public String index(Model model){ 13 | return "index"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-mysql-rest/src/main/java/com/hellokoding/jpa/book/Publisher.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import lombok.*; 4 | 5 | import javax.persistence.*; 6 | import java.util.HashSet; 7 | import java.util.Set; 8 | 9 | @Data 10 | 11 | @Entity 12 | public class Publisher { 13 | @Id 14 | @GeneratedValue(strategy = GenerationType.IDENTITY) 15 | private int id; 16 | 17 | private String name; 18 | 19 | public Publisher(String name) { 20 | this.name = name; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-problems/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:8.0 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | command: mvn clean spring-boot:run 21 | depends_on: 22 | - hk-mysql 23 | -------------------------------------------------------------------------------- /springboot-examples/springboot-email-verification-mysql/src/main/java/com/hellokoding/account/repository/VerificationTokenRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.account.repository; 2 | 3 | import com.hellokoding.account.model.VerificationToken; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | import java.util.List; 7 | 8 | public interface VerificationTokenRepository extends JpaRepository { 9 | List findByUserEmail(String email); 10 | List findByToken(String token); 11 | } 12 | -------------------------------------------------------------------------------- /springboot-examples/springboot-flyway/src/main/java/com/hellokoding/springboot/jpa/book/Book.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.jpa.book; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | 10 | @Entity 11 | @Data 12 | public class Book { 13 | @Id 14 | @GeneratedValue(strategy = GenerationType.IDENTITY) 15 | private int id; 16 | 17 | private String title; 18 | 19 | private String description; 20 | } 21 | -------------------------------------------------------------------------------- /java-examples/java-core/src/test/java/com/hellokoding/java/java14/Records.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.java.java14; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.assertj.core.api.Assertions.assertThat; 6 | 7 | public class Records { 8 | @Test 9 | public void testRecord() { 10 | Book b = new Book(1, "Java 14"); 11 | int id = b.id(); 12 | String title = b.title(); 13 | 14 | assertThat(id).isEqualTo(1); 15 | assertThat(title).isEqualTo("Java 14"); 16 | } 17 | } 18 | 19 | record Book(int id, String title) { 20 | } 21 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mongodb-nginx/app/src/main/java/com/hellokoding/springboot/WebApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; 6 | 7 | @SpringBootApplication 8 | public class WebApplication { 9 | public static void main(String[] args) throws Exception { 10 | SpringApplication.run(WebApplication.class, args); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mysql-nginx/app/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.freemarker.template-loader-path: classpath:/templates 2 | spring.freemarker.suffix: .ftl 3 | 4 | spring.datasource.url=jdbc:mysql://hk-mysql:3306/test?useSSL=false 5 | spring.datasource.username=root 6 | spring.datasource.password=hellokoding 7 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 8 | 9 | spring.jpa.hibernate.ddl-auto=create 10 | spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect 11 | spring.jpa.generate-ddl=true 12 | spring.jpa.show-sql=true -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-mysql/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | command: mvn clean spring-boot:run 21 | depends_on: 22 | - hk-mysql 23 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-mysql/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:8.0 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | command: mvn clean spring-boot:run 21 | depends_on: 22 | - hk-mysql 23 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-mysql/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | command: mvn clean spring-boot:run 21 | depends_on: 22 | - hk-mysql 23 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/springboot-mapstruct-onetomany/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:8.0 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | command: mvn clean spring-boot:run 21 | depends_on: 22 | - hk-mysql 23 | -------------------------------------------------------------------------------- /springboot-examples/springboot-registration-login/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://hk-mysql:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | 11 | spring.mvc.view.prefix: / 12 | spring.mvc.view.suffix: .jsp 13 | spring.messages.basename=validation 14 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-deleting-data/src/main/java/com/hellokoding/jpa/customer/CardRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.customer; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.data.jpa.repository.Modifying; 5 | import org.springframework.data.jpa.repository.Query; 6 | 7 | import java.util.List; 8 | 9 | public interface CardRepository extends JpaRepository { 10 | @Modifying 11 | @Query("DELETE FROM Card c WHERE c.customer.id = ?1") 12 | void deleteByCustomerId(int customerId); 13 | } 14 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-mysql-rest/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:8.0 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | command: mvn clean spring-boot:run 21 | depends_on: 22 | - hk-mysql 23 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-composite-primary-key-mysql/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | command: mvn clean spring-boot:run 21 | depends_on: 22 | - hk-mysql 23 | -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-submission/src/main/java/com/hellokoding/springboot/User.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot; 2 | 3 | public class User { 4 | private String name; 5 | private String message; 6 | 7 | public String getName() { 8 | return name; 9 | } 10 | 11 | public void setName(String name) { 12 | this.name = name; 13 | } 14 | 15 | public String getMessage() { 16 | return message; 17 | } 18 | 19 | public void setMessage(String message) { 20 | this.message = message; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-deleting-data/src/main/java/com/hellokoding/jpa/customer/CardService.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.customer; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | 6 | import javax.transaction.Transactional; 7 | 8 | @Service 9 | @Transactional 10 | public class CardService { 11 | @Autowired 12 | private CardRepository cardRepository; 13 | 14 | public void deleteByCustomerId(Integer customerId) { 15 | cardRepository.deleteByCustomerId(customerId); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-mysql/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | command: mvn clean spring-boot:run 21 | depends_on: 22 | - hk-mysql 23 | -------------------------------------------------------------------------------- /datastructure-algorithm-java-examples/src/main/java/com/hellokoding/algorithm/FibonacciTabular.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.algorithm; 2 | 3 | public class FibonacciTabular { 4 | int fibonacci(int n) { 5 | int[] cache = new int[n+1]; 6 | cache[0] = 0; 7 | cache[1] = 1; 8 | 9 | for (int i = 2; i <= n; i++) { 10 | cache[i] = cache[i-1] + cache[i-2]; 11 | } 12 | 13 | return cache[n]; 14 | } 15 | 16 | public static void main(String[] args) { 17 | System.out.println(new FibonacciTabular().fibonacci(10)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-mysql-rest/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | command: mvn clean spring-boot:run 21 | depends_on: 22 | - hk-mysql 23 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-shared-primary-key-mysql/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | command: mvn clean spring-boot:run 21 | depends_on: 22 | - hk-mysql 23 | -------------------------------------------------------------------------------- /springboot-examples/springboot-flyway/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | ports: 21 | - 8080:8080 22 | command: mvn clean spring-boot:run 23 | depends_on: 24 | - hk-mysql 25 | -------------------------------------------------------------------------------- /springboot-examples/springboot-swagger/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | ports: 21 | - 8080:8080 22 | command: mvn clean spring-boot:run 23 | depends_on: 24 | - hk-mysql 25 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-nginx/nginx/conf.d/app.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | charset utf-8; 4 | access_log off; 5 | 6 | location / { 7 | proxy_pass http://app:8080; 8 | proxy_set_header Host $host:$server_port; 9 | proxy_set_header X-Forwarded-Host $server_name; 10 | proxy_set_header X-Real-IP $remote_addr; 11 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 12 | } 13 | 14 | location /static { 15 | access_log off; 16 | expires 30d; 17 | 18 | alias /app/static; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /springboot-examples/springboot-mapstruct/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | ports: 21 | - 8080:8080 22 | command: mvn clean spring-boot:run 23 | depends_on: 24 | - hk-mysql 25 | -------------------------------------------------------------------------------- /springboot-examples/springboot-security-login-thymeleaf/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /springboot-examples/springboot-uploading-files/src/main/java/com/hellokoding/uploadingfiles/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.uploadingfiles; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | 9 | @SpringBootApplication 10 | public class Application { 11 | public static void main(String[] args) throws IOException { 12 | new File(UploadingController.uploadingDir).mkdirs(); 13 | SpringApplication.run(Application.class, args); 14 | } 15 | } -------------------------------------------------------------------------------- /springboot-examples/springdatarest-mysql-single/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | ports: 21 | - 8080:8080 22 | command: mvn clean spring-boot:run 23 | depends_on: 24 | - hk-mysql 25 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mongodb-nginx/nginx/conf.d/app.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | charset utf-8; 4 | access_log off; 5 | 6 | location / { 7 | proxy_pass http://app:8080; 8 | proxy_set_header Host $host:$server_port; 9 | proxy_set_header X-Forwarded-Host $server_name; 10 | proxy_set_header X-Real-IP $remote_addr; 11 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 12 | } 13 | 14 | location /static { 15 | access_log off; 16 | expires 30d; 17 | 18 | alias /app/static; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /docker-examples/dockercompose-springboot-mysql-nginx/nginx/conf.d/app.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | charset utf-8; 4 | access_log off; 5 | 6 | location / { 7 | proxy_pass http://app:8080; 8 | proxy_set_header Host $host:$server_port; 9 | proxy_set_header X-Forwarded-Host $server_name; 10 | proxy_set_header X-Real-IP $remote_addr; 11 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 12 | } 13 | 14 | location /static { 15 | access_log off; 16 | expires 30d; 17 | 18 | alias /app/static; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /springboot-examples/springboot-email-verification-mysql/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | ports: 21 | - "8080:8080" 22 | command: mvn clean spring-boot:run 23 | depends_on: 24 | - hk-mysql -------------------------------------------------------------------------------- /springboot-examples/springboot-mockmvc-hsql/src/main/java/com/hellokoding/springboot/restful/Stock.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import java.math.BigDecimal; 10 | 11 | @Data 12 | 13 | @Entity 14 | public class Stock { 15 | @Id 16 | @GeneratedValue(strategy = GenerationType.IDENTITY) 17 | private Long id; 18 | 19 | private String name; 20 | 21 | private BigDecimal price; 22 | } 23 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-circular-reference-jackson/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | ports: 21 | - 8080:8080 22 | command: mvn clean spring-boot:run 23 | depends_on: 24 | - hk-mysql 25 | -------------------------------------------------------------------------------- /springboot-examples/springboot-crud-mysql-vuejs/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | crud-mysql-vuejs: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | ports: 21 | - 8080:8080 22 | command: mvn clean spring-boot:run 23 | depends_on: 24 | - hk-mysql 25 | -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi-testing-all-layers/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | hk-app: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | ports: 21 | - 8080:8080 22 | command: mvn clean spring-boot:run 23 | depends_on: 24 | - hk-mysql 25 | -------------------------------------------------------------------------------- /datastructure-algorithm-java-examples/src/main/java/com/hellokoding/algorithm/BinarySearch.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.algorithm; 2 | 3 | public class BinarySearch { 4 | public static int binarySearch(int T, int[] A) { 5 | int N = A.length; 6 | int L = 0; 7 | int R = N - 1; 8 | 9 | while (L <= R) { 10 | int M = (int)Math.floor((L+R)/2); 11 | if (A[M] < T) 12 | L = M + 1; 13 | else if (A[M] > T) 14 | R = M - 1; 15 | else 16 | return M; 17 | } 18 | 19 | return -1; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /springboot-examples/springboot-registration-login/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | registration-login: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | ports: 21 | - 8080:8080 22 | command: mvn clean spring-boot:run 23 | depends_on: 24 | - hk-mysql 25 | -------------------------------------------------------------------------------- /springboot-examples/springboot-registration-login/src/main/java/com/hellokoding/auth/WebApplication.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.auth; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.builder.SpringApplicationBuilder; 6 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 7 | 8 | @SpringBootApplication 9 | public class WebApplication { 10 | public static void main(String[] args) throws Exception { 11 | SpringApplication.run(WebApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /springboot-examples/springboot-todomvc-mysql-vuejs/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | todomvc-mysql-vuejs: 15 | build: . 16 | volumes: 17 | - .:/app 18 | - ~/.m2:/root/.m2 19 | working_dir: /app 20 | ports: 21 | - 8080:8080 22 | command: mvn clean spring-boot:run 23 | depends_on: 24 | - hk-mysql 25 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-crud-deleting-entity/src/main/java/com/hellokoding/jpa/book/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.data.jpa.repository.Modifying; 5 | import org.springframework.data.jpa.repository.Query; 6 | 7 | import java.util.List; 8 | 9 | public interface BookRepository extends JpaRepository { 10 | @Modifying 11 | @Query("DELETE Book b WHERE b.category.id = ?1") 12 | void deleteByCategoryId(int categoryId); 13 | 14 | List findByCategoryId(int categoryId); 15 | } 16 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-mysql/src/main/java/com/hellokoding/jpa/model/IDCard.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.model; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.persistence.*; 7 | import java.util.UUID; 8 | 9 | @Getter @Setter 10 | @Entity 11 | public class IDCard { 12 | @Id 13 | @GeneratedValue(strategy = GenerationType.IDENTITY) 14 | private Integer id; 15 | 16 | @Column(unique = true, nullable = false) 17 | private String code = UUID.randomUUID().toString(); 18 | 19 | @OneToOne(mappedBy = "idCard", optional = false) 20 | private Person person; 21 | } 22 | -------------------------------------------------------------------------------- /java-examples/java-app-healthcheck-prometheus/src/main/java/com/hellokoding/monitoring/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.monitoring; 2 | 3 | import com.github.strengthened.prometheus.healthchecks.HealthChecksCollector; 4 | 5 | public class Application { 6 | public static void main(String[] args) throws Exception { 7 | HealthChecksCollector healthchecksMetrics = HealthChecksCollector.Builder.of().setGaugeMetricName("hello_koding_health_check").build(); 8 | healthchecksMetrics.addHealthCheck("database", new DbHealthCheck()); 9 | 10 | new HealthCheckExporter(healthchecksMetrics).export(); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /java-examples/java-bean-validation/src/main/java/com/hellokoding/validation/ProductCodeExisting.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.validation; 2 | 3 | import javax.validation.Constraint; 4 | import javax.validation.Payload; 5 | import java.lang.annotation.*; 6 | 7 | @Documented 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target({ElementType.FIELD, ElementType.PARAMETER}) 10 | @Constraint(validatedBy = ProductCodeExistingValidator.class) 11 | public @interface ProductCodeExisting { 12 | String message() default "{ProductCodeExisting}"; 13 | 14 | Class[] groups() default { }; 15 | 16 | Class[] payload() default { }; 17 | } 18 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-mysql-rest/src/main/java/com/hellokoding/jpa/book/Book.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.*; 6 | 7 | @Data 8 | 9 | @Entity 10 | public class Book { 11 | @Id 12 | @GeneratedValue(strategy = GenerationType.IDENTITY) 13 | private int id; 14 | 15 | @Column(name = "name") 16 | private String name; 17 | 18 | public Book(String name, BookPublisher... bookPublishers) { 19 | this.name = name; 20 | for(BookPublisher bookPublisher : bookPublishers) bookPublisher.setBook(this); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-mysql/src/main/java/com/hellokoding/jpa/book/Publisher.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import lombok.*; 4 | 5 | import javax.persistence.*; 6 | import java.util.HashSet; 7 | import java.util.Set; 8 | 9 | @Data 10 | 11 | @Entity 12 | public class Publisher { 13 | @Id 14 | @GeneratedValue(strategy = GenerationType.IDENTITY) 15 | private int id; 16 | 17 | private String name; 18 | 19 | @ManyToMany(mappedBy = "publishers") 20 | private Set books = new HashSet<>(); 21 | 22 | public Publisher(String name) { 23 | this.name = name; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-jsp/src/main/webapp/WEB-INF/views/hello.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | Hello ${name}! 10 | 11 | 12 | 13 |

Hello ${name}!

14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-hsql/src/main/java/com/hellokoding/jpa/model/BookPublisherId.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import javax.persistence.Column; 8 | import javax.persistence.Embeddable; 9 | import java.io.Serializable; 10 | 11 | @Data @AllArgsConstructor @NoArgsConstructor 12 | @Embeddable 13 | public class BookPublisherId implements Serializable { 14 | @Column(name = "book_id") 15 | private Integer bookId; 16 | 17 | @Column(name = "publisher_id") 18 | private Integer publisherId; 19 | } 20 | -------------------------------------------------------------------------------- /springboot-examples/springboot-todomvc-mysql-vuejs/src/main/java/com/hellokoding/springboot/fullstack/todo/TodoService.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.fullstack.todo; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.springframework.stereotype.Service; 5 | 6 | import java.util.List; 7 | 8 | @Service 9 | 10 | @RequiredArgsConstructor 11 | public class TodoService { 12 | private final TodoRepository stockRepository; 13 | 14 | public List findAll() { 15 | return stockRepository.findAll(); 16 | } 17 | 18 | public List saveAll(List todos) { 19 | return stockRepository.saveAll(todos); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /springboot-examples/spring-core-examples/src/main/java/com/hellokoding/springcore/ConsumerService.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springcore; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.stereotype.Service; 6 | import org.springframework.web.client.RestTemplate; 7 | 8 | @Service 9 | public class ConsumerService { 10 | @Autowired 11 | RestTemplate restTemplateWithErrorHandler; 12 | 13 | public ResponseEntity consume(String url, Class responseType) { 14 | return restTemplateWithErrorHandler.getForEntity(url, responseType); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /springboot-examples/springboot-caching-redis/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://hk-mysql:3306/test?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=hellokoding 4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 5 | 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.jpa.database-platform=org.hibernate.dialect.MySQL57Dialect 8 | spring.jpa.generate-ddl=true 9 | spring.jpa.show-sql=true 10 | 11 | spring.redis.host=hk-redis 12 | spring.redis.timeout=2000 13 | spring.cache.redis.key-prefix=hellokoding:: 14 | spring.cache.redis.time-to-live=100000 15 | spring.data.redis.repositories.enabled=false -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-composite-primary-key-mysql/src/main/java/com/hellokoding/jpa/EmployeePhone.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.persistence.*; 7 | 8 | @Getter @Setter 9 | @Entity 10 | @IdClass(EmployeePhoneId.class) 11 | public class EmployeePhone { 12 | @ManyToOne 13 | @PrimaryKeyJoinColumn 14 | private Employee employee; 15 | 16 | @Id 17 | private String phone; 18 | 19 | private Boolean isPrimary; 20 | 21 | public EmployeePhone(String phone, Boolean isPrimary) { 22 | this.phone = phone; 23 | this.isPrimary = isPrimary; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-hsql/src/main/java/com/hellokoding/jpa/model/Publisher.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.model; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.*; 6 | import java.util.HashSet; 7 | import java.util.Set; 8 | 9 | @Data 10 | @Entity 11 | public class Publisher { 12 | @Id 13 | @GeneratedValue(strategy = GenerationType.IDENTITY) 14 | private Integer id; 15 | 16 | private String name; 17 | 18 | @OneToMany(mappedBy = "publisher") 19 | private Set bookPublishers = new HashSet<>(); 20 | 21 | public Publisher(String name){ 22 | this.name = name; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /springboot-examples/springboot-jsp-helloworld/src/main/java/com/hellokoding/springboot/view/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.view; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @Controller 9 | public class HelloController { 10 | @GetMapping({"/", "/hello"}) 11 | public String hello(Model model, @RequestParam(value="name", required=false, defaultValue="World") String name) { 12 | model.addAttribute("name", name); 13 | return "hello"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /springboot-examples/springboot-thymeleaf-helloworld/src/main/java/com/hellokoding/springboot/view/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.view; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @Controller 9 | public class HelloController { 10 | @GetMapping({"/", "/hello"}) 11 | public String hello(Model model, @RequestParam(value="name", required=false, defaultValue="World") String name) { 12 | model.addAttribute("name", name); 13 | return "hello"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /java-examples/java-core/src/main/java/com/hellokoding/java/collections/StringSortAscending.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.java.collections; 2 | 3 | import java.util.Arrays; 4 | 5 | public class StringSortAscending { 6 | static String sortAsc(String str) { 7 | // convert String to char array 8 | char[] arr = str.toCharArray(); 9 | 10 | // sort char array in alphabetically / ascending order 11 | Arrays.sort(arr); 12 | 13 | // String join char array 14 | return String.valueOf(arr); 15 | } 16 | 17 | public static void main(String[] args) { 18 | String str = "bac"; 19 | System.out.println(sortAsc(str)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-shared-primary-key-mysql/src/main/java/com/hellokoding/jpa/model/IDCard.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.model; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.persistence.*; 7 | import java.util.UUID; 8 | 9 | @Getter @Setter 10 | @Entity 11 | public class IDCard { 12 | @Id 13 | @GeneratedValue(strategy = GenerationType.IDENTITY) 14 | private int id; 15 | 16 | @OneToOne(optional = false) 17 | @JoinColumn(name = "person_id") 18 | @MapsId 19 | private Person person; 20 | 21 | @Column(unique = true, nullable = false) 22 | private String code = UUID.randomUUID().toString(); 23 | } 24 | -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi-validation/src/main/java/com/hellokoding/springboot/restful/product/ProductIDExisting.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful.product; 2 | 3 | import javax.validation.Constraint; 4 | import javax.validation.Payload; 5 | import java.lang.annotation.*; 6 | 7 | @Documented 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target({ElementType.FIELD, ElementType.PARAMETER}) 10 | @Constraint(validatedBy = ProductIDExistingValidator.class) 11 | public @interface ProductIDExisting { 12 | String message() default "{ProductIDExisting}"; 13 | 14 | Class[] groups() default { }; 15 | 16 | Class[] payload() default { }; 17 | } 18 | -------------------------------------------------------------------------------- /datastructure-algorithm-java-examples/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.hellokoding.algorithm 8 | datastructure-algorithm-java 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 1.8 13 | 1.8 14 | 15 | -------------------------------------------------------------------------------- /java-examples/java-core/src/test/java/com/hellokoding/java/collections/Java9CollectionFactoryMethodsTest.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.java.collections; 2 | 3 | import org.assertj.core.api.ThrowableAssert; 4 | import org.junit.Test; 5 | 6 | import java.util.HashSet; 7 | import java.util.List; 8 | 9 | import static org.assertj.core.api.Assertions.assertThatThrownBy; 10 | 11 | public class Java9CollectionFactoryMethodsTest { 12 | @Test 13 | public void initNullWithListOfAndSetOf() { 14 | String s = null; 15 | ThrowableAssert.ThrowingCallable c = () -> new HashSet<>(List.of(s)); 16 | 17 | assertThatThrownBy(c).isInstanceOf(NullPointerException.class); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /springboot-examples/spring-core-examples/src/main/java/com/hellokoding/springcore/RestTemplateWithErrorHandlerConfig.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springcore; 2 | 3 | import org.springframework.boot.web.client.RestTemplateBuilder; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.client.RestTemplate; 7 | 8 | @Configuration 9 | public class RestTemplateWithErrorHandlerConfig { 10 | @Bean 11 | RestTemplate restTemplateWithErrorHandler() { 12 | return new RestTemplateBuilder() 13 | .errorHandler(new CustomResponseErrorHandler()) 14 | .build(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi-testing-all-layers/src/main/java/com/hellokoding/springboot/restful/product/ProductDTO.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful.product; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.math.BigDecimal; 8 | 9 | @Data 10 | @NoArgsConstructor 11 | @Builder 12 | public class ProductDTO { 13 | private String name; 14 | private String description; 15 | private BigDecimal price; 16 | 17 | public ProductDTO(String name, String description, BigDecimal price) { 18 | this.name = name; 19 | this.description = description; 20 | this.price = price; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /springboot-examples/springboot-single-sign-on-jwt/auth-service/src/main/resources/templates/login.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Authentication Service 5 | 6 | 7 |
8 |

Log in

9 | 11 | 12 |
(try username=hellokoding and password=hellokoding)
13 |
${error!}
14 |
15 | 16 |
17 | 18 | -------------------------------------------------------------------------------- /springboot-examples/springboot-single-sign-out-jwt/auth-service/src/main/resources/templates/login.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Authentication Service 5 | 6 | 7 |
8 |

Log in

9 | 11 | 12 |
(try username=hellokoding and password=hellokoding)
13 |
${error!}
14 |
15 | 16 |
17 | 18 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-circular-reference-jackson/src/main/java/com/hellokoding/jpa/book/Author.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | 7 | import javax.persistence.*; 8 | import java.util.Set; 9 | 10 | @Entity 11 | 12 | @Data 13 | @EqualsAndHashCode(exclude = "books") 14 | public class Author { 15 | @Id 16 | @GeneratedValue(strategy = GenerationType.IDENTITY) 17 | private int id; 18 | 19 | private String name; 20 | 21 | @ManyToMany(mappedBy = "authors") 22 | @JsonIgnoreProperties("authors") 23 | private Set books; 24 | } 25 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-mysql/src/main/java/com/hellokoding/jpa/book/Publisher.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import lombok.*; 4 | 5 | import javax.persistence.*; 6 | import java.util.HashSet; 7 | import java.util.Set; 8 | 9 | @Data 10 | 11 | @Entity 12 | public class Publisher { 13 | @Id 14 | @GeneratedValue(strategy = GenerationType.IDENTITY) 15 | private int id; 16 | 17 | private String name; 18 | 19 | @OneToMany(mappedBy = "publisher", cascade = CascadeType.ALL) 20 | private Set bookPublishers = new HashSet<>(); 21 | 22 | public Publisher(String name) { 23 | this.name = name; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /datastructure-algorithm-java-examples/src/main/java/com/hellokoding/algorithm/FibonacciMemoization.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.algorithm; 2 | 3 | public class FibonacciMemoization { 4 | int[] cache; 5 | 6 | FibonacciMemoization(int[] cache){ 7 | this.cache = cache; 8 | } 9 | 10 | int fibonacci(int n) { 11 | if (cache[n] == 0) { 12 | if (n < 2) cache[n] = n; 13 | else cache[n] = fibonacci(n-1) + fibonacci( n-2); 14 | } 15 | 16 | return cache[n]; 17 | } 18 | 19 | public static void main(String[] args) { 20 | int n = 10; 21 | System.out.println(new FibonacciMemoization(new int[n+1]).fibonacci(n)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /java-examples/java-core/src/test/java/com/hellokoding/java/concurrent/CallableCounter.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.java.concurrent; 2 | 3 | import java.util.concurrent.Callable; 4 | import java.util.concurrent.atomic.AtomicInteger; 5 | 6 | public class CallableCounter implements Callable { 7 | private AtomicInteger counter; 8 | 9 | CallableCounter(AtomicInteger counter) { 10 | this.counter = counter; 11 | } 12 | 13 | @Override 14 | public AtomicInteger call() throws Exception { 15 | for (int i = 0; i < 100; i++) { 16 | counter.getAndIncrement(); 17 | Thread.sleep(10); 18 | } 19 | 20 | return counter; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-many-to-many-extra-columns-hsql/src/main/java/com/hellokoding/jpa/model/Book.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.model; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.*; 6 | import java.util.HashSet; 7 | import java.util.Set; 8 | 9 | @Data 10 | @Entity 11 | public class Book{ 12 | @Id 13 | @GeneratedValue(strategy = GenerationType.IDENTITY) 14 | private Integer id; 15 | 16 | private String name; 17 | 18 | @OneToMany(mappedBy = "book", cascade = CascadeType.ALL, orphanRemoval = true) 19 | private Set bookPublishers = new HashSet<>(); 20 | 21 | public Book(String name) { 22 | this.name = name; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /springboot-examples/springboot-caching-redis/src/main/java/com/hellokoding/springboot/caching/configuration/CustomKeyGenerator.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.caching.configuration; 2 | 3 | import org.springframework.cache.interceptor.KeyGenerator; 4 | import org.springframework.util.StringUtils; 5 | 6 | import java.lang.reflect.Method; 7 | 8 | public class CustomKeyGenerator implements KeyGenerator { 9 | @Override 10 | public Object generate(Object o, Method method, Object... params) { 11 | return String.format("%s_%s_%s", 12 | o.getClass().getSimpleName(), 13 | method.getName(), 14 | StringUtils.arrayToDelimitedString(params, "_")); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-helloworld/src/main/java/com/hellokoding/springboot/view/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.view; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @Controller 9 | public class HelloController { 10 | @GetMapping({"/", "/hello"}) 11 | public String hello(Model model, 12 | @RequestParam(value="name", required=false, defaultValue="World") String name) { 13 | model.addAttribute("name", name); 14 | return "hello"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /java-examples/java-core/src/test/java/com/hellokoding/java/concurrent/ThreadCounter.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.java.concurrent; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | 5 | public class ThreadCounter extends Thread { 6 | private AtomicInteger counter; 7 | 8 | ThreadCounter(AtomicInteger counter) { 9 | this.counter = counter; 10 | } 11 | 12 | @Override 13 | public void run() { 14 | for (int i = 0; i < 100; i++) { 15 | counter.getAndIncrement(); 16 | try { 17 | Thread.sleep(10); 18 | } catch (InterruptedException e) { 19 | e.printStackTrace(); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /springboot-examples/springboot-caching-redis/src/main/java/com/hellokoding/springboot/caching/product/Product.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.caching.product; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import java.io.Serializable; 10 | import java.math.BigDecimal; 11 | 12 | @Data 13 | @Entity 14 | public class Product implements Serializable { 15 | @Id 16 | @GeneratedValue(strategy = GenerationType.IDENTITY) 17 | private Long id; 18 | 19 | private String name; 20 | 21 | private String description; 22 | 23 | private BigDecimal price; 24 | } 25 | -------------------------------------------------------------------------------- /java-examples/java-core/src/test/java/com/hellokoding/java/concurrent/RunnableCounter.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.java.concurrent; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | 5 | public class RunnableCounter implements Runnable{ 6 | private AtomicInteger counter; 7 | 8 | RunnableCounter(AtomicInteger counter) { 9 | this.counter = counter; 10 | } 11 | 12 | @Override 13 | public void run() { 14 | for (int i = 0; i < 100; i++) { 15 | counter.getAndIncrement(); 16 | try { 17 | Thread.sleep(10); 18 | } catch (InterruptedException e) { 19 | e.printStackTrace(); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-shared-primary-key-mysql/src/main/java/com/hellokoding/jpa/model/Person.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.model; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.persistence.*; 7 | 8 | @Getter 9 | @Setter 10 | @Entity 11 | public class Person { 12 | @Id 13 | @GeneratedValue(strategy = GenerationType.IDENTITY) 14 | private int id; 15 | 16 | private String name; 17 | 18 | @OneToOne(cascade = CascadeType.ALL, mappedBy = "person") 19 | private IDCard idCard; 20 | 21 | public Person(String name, IDCard idCard) { 22 | this.name = name; 23 | this.idCard = idCard; 24 | this.idCard.setPerson(this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-circular-reference-jackson/src/main/java/com/hellokoding/jpa/book/Category.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | 7 | import javax.persistence.*; 8 | import java.util.Set; 9 | 10 | @Entity 11 | 12 | @Data 13 | @EqualsAndHashCode(exclude = "books") 14 | public class Category { 15 | @Id 16 | @GeneratedValue(strategy = GenerationType.IDENTITY) 17 | private int id; 18 | 19 | private String name; 20 | 21 | @OneToMany(mappedBy = "category", cascade = CascadeType.ALL) 22 | @JsonIgnoreProperties("category") 23 | private Set books; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-jsp/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %date{HH:mm:ss.SSS} [%thread] %-5level %logger{15}#%line %msg\n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-thymeleaf/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %date{HH:mm:ss.SSS} [%thread] %-5level %logger{15}#%line %msg\n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /java-examples/java-core/src/test/java/com/hellokoding/java/lang/BookWithEquals.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.java.lang; 2 | 3 | 4 | import java.util.Objects; 5 | 6 | public class BookWithEquals { 7 | public String title; 8 | public Integer pages; 9 | 10 | public BookWithEquals(String title, Integer pages) { 11 | this.title = title; 12 | this.pages = pages; 13 | } 14 | 15 | @Override 16 | public boolean equals(Object o) { 17 | if (this == o) return true; 18 | if (o == null || getClass() != o.getClass()) return false; 19 | BookWithEquals that = (BookWithEquals) o; 20 | return Objects.equals(title, that.title) && 21 | Objects.equals(pages, that.pages); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /java-examples/java-properties-file/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.hellokoding.util 8 | properties-file-java 9 | 1.0-SNAPSHOT 10 | 11 | 12 | com.hellokoding.util.Main 13 | 1.8 14 | 1.8 15 | 16 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-mysql/src/main/java/com/hellokoding/jpa/model/Person.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.model; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.persistence.*; 7 | 8 | @Getter 9 | @Setter 10 | @Entity 11 | public class Person { 12 | @Id 13 | @GeneratedValue(strategy = GenerationType.IDENTITY) 14 | private int id; 15 | 16 | private String name; 17 | 18 | @OneToOne(cascade = CascadeType.ALL, optional = false) 19 | @JoinColumn(name = "id_card_id") 20 | private IDCard idCard; 21 | 22 | public Person(String name, IDCard idCard) { 23 | this.name = name; 24 | this.idCard = idCard; 25 | this.idCard.setPerson(this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /datastructure-algorithm-java-examples/src/main/java/com/hellokoding/algorithm/SmallestMissingPositiveNumberBySorting.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.algorithm; 2 | 3 | import java.util.Arrays; 4 | 5 | public class SmallestMissingPositiveNumberBySorting { 6 | public static int findSmallest(int[] a) { 7 | Arrays.sort(a); 8 | int min = 1; 9 | 10 | for (int i = 0; i < a.length; i++) { 11 | if (min == a[i]) { 12 | min++; 13 | } 14 | } 15 | 16 | return min; 17 | } 18 | 19 | public static void main(String[] args) { 20 | System.out.println(findSmallest(new int[]{1, 3, 6, 4, 1, 2})); 21 | System.out.println(findSmallest(new int[]{-1, -3, 5})); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-mvc-examples/registration-login-spring-xml-maven-jsp-mysql/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %date{HH:mm:ss.SSS} [%thread] %-5level %logger{15}#%line %msg\n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-jsp/src/main/webapp/WEB-INF/appconfig-root.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /datastructure-algorithm-java-examples/src/main/java/com/hellokoding/algorithm/SubarrayMaxSumBruteforce.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.algorithm; 2 | 3 | public class SubarrayMaxSumBruteforce { 4 | public static int maxSumBruteforce(int[] A, int k) { 5 | int maxSum = Integer.MIN_VALUE; 6 | 7 | for (int i = 0; i < A.length - k + 1; i++) { 8 | int currentSum = 0; 9 | 10 | for (int j = 0; j < k; j++) { 11 | currentSum += A[i+j]; 12 | } 13 | 14 | if (currentSum > maxSum) maxSum = currentSum; 15 | } 16 | 17 | return maxSum; 18 | } 19 | 20 | public static void main(String[] args) { 21 | System.out.println(maxSumBruteforce(new int[]{5, 7, 2, 9, 4}, 2)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /docker-examples/docker-compose-nginx-jetty-mysql/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | nginx: 4 | container_name: some-nginx 5 | image: nginx:1.13 6 | restart: always 7 | ports: 8 | - 80:80 9 | - 443:443 10 | volumes: 11 | - ./nginx-site-enabled:/etc/nginx/sites-enabled 12 | networks: 13 | - front 14 | 15 | jetty: 16 | container_name: some-jetty 17 | image: jetty:9.4-jre8 18 | restart: always 19 | networks: 20 | - front 21 | - back 22 | 23 | mysql: 24 | container_name: some-mysql 25 | image: mysql/mysql-server:5.7 26 | environment: 27 | MYSQL_ROOT_PASSWORD: hellokoding 28 | ports: 29 | - "3306:3306" 30 | restart: always 31 | networks: 32 | - back 33 | 34 | networks: 35 | front: 36 | back: -------------------------------------------------------------------------------- /springboot-examples/spring-security-oauth2/src/main/java/com/hellokoding/springboot/oauth2/OAuth2Controller.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.oauth2; 2 | 3 | import org.springframework.security.core.annotation.AuthenticationPrincipal; 4 | import org.springframework.security.oauth2.core.user.OAuth2User; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import java.util.Collections; 9 | import java.util.Map; 10 | 11 | @RestController 12 | public class OAuth2Controller { 13 | @GetMapping("/user") 14 | public Map user(@AuthenticationPrincipal OAuth2User principal) { 15 | return Collections.singletonMap("name", principal.getAttribute("name")); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /springboot-examples/springboot-caching-redis/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | hk-mysql: 4 | container_name: hk-mysql 5 | image: mysql/mysql-server:5.7 6 | environment: 7 | MYSQL_DATABASE: test 8 | MYSQL_ROOT_PASSWORD: hellokoding 9 | MYSQL_ROOT_HOST: '%' 10 | ports: 11 | - "3306:3306" 12 | restart: always 13 | 14 | hk-redis: 15 | container_name: hk-redis 16 | image: redis:5 17 | ports: 18 | - "6379:6379" 19 | restart: always 20 | 21 | app: 22 | build: . 23 | volumes: 24 | - .:/app 25 | - ~/.m2:/root/.m2 26 | working_dir: /app 27 | ports: 28 | - 8080:8080 29 | command: mvn clean spring-boot:run 30 | depends_on: 31 | - hk-mysql 32 | - hk-redis 33 | -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-thymeleaf/src/main/webapp/WEB-INF/appconfig-root.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /datastructure-algorithm-java-examples/src/main/java/com/hellokoding/algorithm/SubarrayMaxSumWindowSliding.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.algorithm; 2 | 3 | public class SubarrayMaxSumWindowSliding { 4 | public static int maxSumWindowSliding(int[] A, int k) { 5 | int windowsSum = 0, maxSum = Integer.MIN_VALUE; 6 | 7 | for (int i = 0; i < k; i++) { 8 | windowsSum += A[i]; 9 | } 10 | 11 | for (int i = k; i < A.length; i++) { 12 | windowsSum += A[i] - A[i-k]; 13 | if (windowsSum > maxSum) maxSum = windowsSum; 14 | } 15 | 16 | return maxSum; 17 | } 18 | 19 | public static void main(String[] args) { 20 | System.out.println(maxSumWindowSliding(new int[]{-5, -7, -2, -9, -4}, 2)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-jsp/src/main/java/com/hellokoding/springmvc/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springmvc; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | 10 | @Controller 11 | public class HelloController { 12 | @GetMapping({"/", "/hello"}) 13 | public String hello(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) { 14 | model.addAttribute("name", name); 15 | return "hello"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /springboot-examples/springboot-nested-properties-file/src/main/java/com/hellokoding/util/NestedProperties.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.util; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "nested") 8 | public class NestedProperties { 9 | public static class A { 10 | private String b; 11 | 12 | public String getB() { 13 | return b; 14 | } 15 | 16 | public void setB(String b) { 17 | this.b = b; 18 | } 19 | } 20 | 21 | private A a; 22 | 23 | public A getA() { 24 | return a; 25 | } 26 | 27 | public void setA(A a) { 28 | this.a = a; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /java-examples/java-jooq-mysql/src/main/java/com/hellokoding/jooq/model/Tables.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This class is generated by jOOQ 3 | */ 4 | package com.hellokoding.jooq.model; 5 | 6 | 7 | import com.hellokoding.jooq.model.tables.Author; 8 | 9 | import javax.annotation.Generated; 10 | 11 | 12 | /** 13 | * Convenience access to all tables in library 14 | */ 15 | @Generated( 16 | value = { 17 | "http://www.jooq.org", 18 | "jOOQ version:3.8.3" 19 | }, 20 | comments = "This class is generated by jOOQ" 21 | ) 22 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 23 | public class Tables { 24 | 25 | /** 26 | * The table library.author. 27 | */ 28 | public static final Author AUTHOR = com.hellokoding.jooq.model.tables.Author.AUTHOR; 29 | } 30 | -------------------------------------------------------------------------------- /spring-mvc-examples/springmvc-xml-thymeleaf/src/main/java/com/hellokoding/springmvc/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springmvc; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | 10 | @Controller 11 | public class HelloController { 12 | @GetMapping({"/", "/hello"}) 13 | public String hello(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) { 14 | model.addAttribute("name", name); 15 | return "hello"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /datastructure-algorithm-java-examples/src/main/java/com/hellokoding/algorithm/BinaryTreeHeight.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.algorithm; 2 | 3 | import com.hellokoding.datastructure.BSTByLinkedList; 4 | 5 | public class BinaryTreeHeight extends BSTByLinkedList { 6 | public int height(Node node) { 7 | if (node == null) return -1; 8 | 9 | return Math.max(height(node.left), height(node.right)) + 1; 10 | } 11 | 12 | public static void main(String[] args) { 13 | BinaryTreeHeight tree = new BinaryTreeHeight(); 14 | tree.insert(7); 15 | tree.insert(2); 16 | tree.insert(3); 17 | tree.insert(1); 18 | tree.insert(9); 19 | 20 | tree.inTraversal(tree.root); 21 | System.out.println(tree.height(tree.root)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-one-hsql/src/main/java/com/hellokoding/jpa/model/IDCard.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.model; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.persistence.*; 7 | import java.util.UUID; 8 | 9 | @Getter @Setter 10 | @Entity 11 | public class IDCard { 12 | @Id 13 | @GeneratedValue(strategy = GenerationType.IDENTITY) 14 | private int personId; 15 | 16 | @OneToOne(cascade = CascadeType.ALL, optional = false) 17 | @PrimaryKeyJoinColumn(name = "person_id", referencedColumnName = "id") 18 | private Person person; 19 | 20 | @Column(unique = true, nullable = false) 21 | private String code = UUID.randomUUID().toString(); 22 | 23 | public IDCard(Person person) { 24 | this.person = person; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-circular-reference-jackson/src/main/java/com/hellokoding/jpa/book/BookPublisher.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import lombok.Data; 5 | 6 | import javax.persistence.*; 7 | import java.util.Date; 8 | 9 | @Entity 10 | 11 | @Data 12 | public class BookPublisher { 13 | @Id 14 | @GeneratedValue(strategy = GenerationType.IDENTITY) 15 | private int id; 16 | 17 | @ManyToOne 18 | @JoinColumn(name = "book_id") 19 | @JsonIgnoreProperties("bookPublishers") 20 | private Book book; 21 | 22 | @ManyToOne 23 | @JoinColumn(name = "publisher_id") 24 | @JsonIgnoreProperties("bookPublishers") 25 | private Publisher publisher; 26 | 27 | private Date publishedDate; 28 | } 29 | -------------------------------------------------------------------------------- /spring-examples/spring-webflux/src/main/java/com/hellokoding/spring/HelloHandler.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.spring; 2 | 3 | import org.springframework.http.MediaType; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.reactive.function.server.ServerRequest; 6 | import org.springframework.web.reactive.function.server.ServerResponse; 7 | import reactor.core.publisher.Mono; 8 | 9 | @Component 10 | public class HelloHandler { 11 | public Mono hello(ServerRequest request) { 12 | String name = request 13 | .queryParam("name") 14 | .orElse("Spring WebFlux"); 15 | 16 | return ServerResponse.ok() 17 | .contentType(MediaType.TEXT_PLAIN) 18 | .bodyValue(String.format("Hello, %s!", name)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /springboot-examples/springboot-caching-redis/src/main/java/com/hellokoding/springboot/caching/configuration/CachingConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.caching.configuration; 2 | 3 | import org.springframework.cache.annotation.CachingConfigurerSupport; 4 | import org.springframework.cache.interceptor.CacheErrorHandler; 5 | import org.springframework.cache.interceptor.KeyGenerator; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | public class CachingConfiguration extends CachingConfigurerSupport { 10 | @Override 11 | public KeyGenerator keyGenerator() { 12 | return new CustomKeyGenerator(); 13 | } 14 | 15 | @Override 16 | public CacheErrorHandler errorHandler() { 17 | return new CustomCacheErrorHandler(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /datastructure-algorithm-java-examples/src/main/java/com/hellokoding/algorithm/ReverseWordsBySplittingAndIterative.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.algorithm; 2 | 3 | public class ReverseWordsBySplittingAndIterative { 4 | static String reverseWords(String s) { 5 | StringBuilder result = new StringBuilder(); 6 | 7 | String[] words = s.split(" "); 8 | for (int i = words.length - 1; i >= 0; i--) { 9 | if (!words[i].isEmpty()) { 10 | result.append(words[i]).append(" "); 11 | } 12 | } 13 | 14 | return result.toString().trim(); 15 | } 16 | 17 | public static void main(String[] args) { 18 | System.out.println(reverseWords("Hello Koding")); 19 | System.out.println(reverseWords(" Live on time, emit no evil ")); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-examples/spring-aop-example/src/main/java/com/hellokoding/spring/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.spring; 2 | 3 | import org.springframework.boot.CommandLineRunner; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.ApplicationContext; 7 | import org.springframework.context.annotation.Bean; 8 | 9 | @SpringBootApplication 10 | public class Application { 11 | public static void main(String[] args) { 12 | SpringApplication.run(Application.class, args); 13 | } 14 | 15 | @Bean 16 | @LogExecutionTime 17 | public CommandLineRunner commandLineRunner(ApplicationContext ctx) { 18 | return args -> { 19 | Thread.sleep(100); 20 | }; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /springboot-examples/springboot-todomvc-mysql-vuejs/src/main/java/com/hellokoding/springboot/fullstack/todo/Todo.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.fullstack.todo; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import javax.validation.constraints.NotNull; 10 | import javax.validation.constraints.Size; 11 | import java.util.Date; 12 | 13 | @Entity 14 | 15 | @Data 16 | public class Todo { 17 | @Id 18 | @GeneratedValue(strategy = GenerationType.IDENTITY) 19 | private Long id; 20 | 21 | @NotNull 22 | @Size(min = 2, max = 100) 23 | private String title; 24 | 25 | private boolean completed; 26 | 27 | private Date updatedDate = new Date(); 28 | } 29 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-one-to-many-mysql-rest/src/main/java/com/hellokoding/jpa/unidirectional/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.unidirectional; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.Modifying; 7 | import org.springframework.data.jpa.repository.Query; 8 | 9 | import javax.transaction.Transactional; 10 | 11 | public interface BookRepository extends JpaRepository{ 12 | Page findByLibraryId(Integer libraryId, Pageable pageable); 13 | 14 | @Modifying 15 | @Transactional 16 | @Query("DELETE FROM Book b WHERE b.library.id = ?1") 17 | void deleteByLibraryId(Integer libraryId); 18 | } 19 | -------------------------------------------------------------------------------- /springboot-examples/springboot-freemarker-form-submission/src/main/java/com/hellokoding/springboot/FormController.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | 8 | @Controller 9 | public class FormController { 10 | @GetMapping("/") 11 | public String index() { 12 | return "redirect:/form"; 13 | } 14 | 15 | @GetMapping("/form") 16 | public String formGet() { 17 | return "form"; 18 | } 19 | 20 | @PostMapping("/form") 21 | public String formPost(User user, Model model) { 22 | model.addAttribute("user", user); 23 | return "form"; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/jpa-hibernate-circular-reference-jackson/src/main/java/com/hellokoding/jpa/book/Publisher.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.jpa.book; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | 7 | import javax.persistence.*; 8 | import java.util.HashSet; 9 | import java.util.Set; 10 | 11 | @Entity 12 | 13 | @Data 14 | @EqualsAndHashCode(exclude = "bookPublishers") 15 | public class Publisher { 16 | @Id 17 | @GeneratedValue(strategy = GenerationType.IDENTITY) 18 | private int id; 19 | 20 | private String name; 21 | 22 | @OneToMany(mappedBy = "publisher", cascade = CascadeType.ALL, orphanRemoval = true) 23 | @JsonIgnoreProperties("publisher") 24 | private Set bookPublishers = new HashSet<>(); 25 | } 26 | -------------------------------------------------------------------------------- /jpa-hibernate-examples/springboot-mapstruct-onetomany/src/main/java/com/hellokoding/springboot/unidirectional/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.unidirectional; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.Modifying; 7 | import org.springframework.data.jpa.repository.Query; 8 | 9 | import javax.transaction.Transactional; 10 | 11 | public interface BookRepository extends JpaRepository{ 12 | Page findByLibraryId(Integer libraryId, Pageable pageable); 13 | 14 | @Modifying 15 | @Transactional 16 | @Query("DELETE FROM Book b WHERE b.library.id = ?1") 17 | void deleteByLibraryId(Integer libraryId); 18 | } 19 | -------------------------------------------------------------------------------- /datastructure-algorithm-java-examples/src/main/java/com/hellokoding/algorithm/AnagramsBySorting.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.algorithm; 2 | 3 | import java.util.Arrays; 4 | 5 | public class AnagramsBySorting { 6 | static boolean areAnagrams(String s, String t) { 7 | if (s.length() != t.length()) { 8 | return false; 9 | } 10 | 11 | char[] a1 = s.toCharArray(); 12 | char[] a2 = t.toCharArray(); 13 | 14 | Arrays.sort(a1); 15 | Arrays.sort(a2); 16 | 17 | return Arrays.equals(a1, a2); 18 | } 19 | 20 | public static void main(String[] args) { 21 | System.out.println(areAnagrams("listen", "silent")); 22 | System.out.println(areAnagrams("eleven plus two", "twelve plus one")); 23 | System.out.println(areAnagrams("rat", "car")); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /datastructure-algorithm-java-examples/src/main/java/com/hellokoding/algorithm/ReverseWordsByIterative.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.algorithm; 2 | 3 | public class ReverseWordsByIterative { 4 | static String reverseWords(String s) { 5 | StringBuilder result = new StringBuilder(); 6 | int j = s.length(); 7 | 8 | for (int i = j-1; i >= 0; i--) { 9 | char c = s.charAt(i); 10 | if(Character.isWhitespace(c) || i==0) { 11 | result.append(s, i, j); 12 | j = i; 13 | } 14 | } 15 | 16 | return result.toString().trim(); 17 | } 18 | 19 | public static void main(String[] args) { 20 | System.out.println(reverseWords("Hello Koding")); 21 | System.out.println(reverseWords(" Live on time, emit no evil ")); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /springboot-examples/springboot-flyway/src/main/java/com/hellokoding/springboot/jpa/Application.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.jpa; 2 | 3 | import com.hellokoding.springboot.jpa.book.BookRepository; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.context.annotation.Bean; 9 | 10 | @SpringBootApplication 11 | @Slf4j 12 | class Application { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(Application.class, args); 16 | } 17 | 18 | @Bean 19 | public CommandLineRunner runner(BookRepository repository) { 20 | return r -> log.info(repository.findAll().toString()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /java-examples/java-core/src/main/java/com/hellokoding/java/collections/StringSortDescendingByStringBuilder.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.java.collections; 2 | 3 | import java.util.Arrays; 4 | 5 | public class StringSortDescendingByStringBuilder { 6 | static String sortAsc(String str) { 7 | // convert String to char array 8 | char[] arr = str.toCharArray(); 9 | 10 | // sort char array in alphabetically / ascending order 11 | Arrays.sort(arr); 12 | 13 | // String join char array 14 | return String.valueOf(arr); 15 | } 16 | 17 | static String sortDesc(String str) { 18 | return new StringBuilder(sortAsc(str)).reverse().toString(); 19 | } 20 | 21 | public static void main(String[] args) { 22 | String str = "bac"; 23 | System.out.println(sortDesc(str)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /springboot-examples/springboot-restapi-validation/src/main/java/com/hellokoding/springboot/restful/product/ProductIDExistingValidator.java: -------------------------------------------------------------------------------- 1 | package com.hellokoding.springboot.restful.product; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Component; 5 | 6 | import javax.validation.ConstraintValidator; 7 | import javax.validation.ConstraintValidatorContext; 8 | import java.util.Objects; 9 | 10 | @Component 11 | public class ProductIDExistingValidator implements ConstraintValidator { 12 | @Autowired 13 | private ProductService productService; 14 | 15 | @Override 16 | public boolean isValid(Long productId, ConstraintValidatorContext context) { 17 | return Objects.isNull(productId) || productService.findById(productId).isPresent(); 18 | } 19 | } 20 | --------------------------------------------------------------------------------