├── .gitattributes ├── .gitignore ├── README.md ├── api-versioning ├── .gitattributes ├── .gitignore ├── build.gradle.kts ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── http │ ├── request-error.http │ └── request.http ├── settings.gradle.kts └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── version │ │ │ └── api │ │ │ ├── ApiApplication.java │ │ │ ├── config │ │ │ └── WebMvcConfig.java │ │ │ └── controller │ │ │ ├── accept │ │ │ └── AcceptHeaderVersionController.java │ │ │ ├── header │ │ │ └── HeaderVersionController.java │ │ │ ├── parameter │ │ │ └── ParameterVersionController.java │ │ │ └── uri │ │ │ ├── UriVersionControllerV1.java │ │ │ └── UriVersionControllerV2.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── version │ └── api │ └── ApiApplicationTests.java ├── argument-resolver ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── argument │ │ │ └── resolver │ │ │ ├── ResolverApplication.java │ │ │ ├── api │ │ │ ├── Person.java │ │ │ ├── TestController.java │ │ │ └── resolver │ │ │ │ └── PersonArgumentResolver.java │ │ │ └── config │ │ │ └── WebConfigurer.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── argument │ └── resolver │ └── resolver │ └── ResolverApplicationTests.java ├── auth0-integration ├── HELP.md ├── build.gradle.kts ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── oauth0 │ │ │ └── demo │ │ │ ├── DemoApplication.java │ │ │ ├── config │ │ │ └── security │ │ │ │ ├── LogoutHandler.java │ │ │ │ └── SecurityConfig.java │ │ │ └── controller │ │ │ └── LoginController.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── oauth0 │ └── demo │ └── DemoApplicationTests.java ├── bean-post-processor ├── .gitignore ├── README.md ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── beanpostprocessor │ │ │ ├── BB2Component.java │ │ │ ├── BBComponent.java │ │ │ ├── BeanPostProcessorApplication.java │ │ │ └── special │ │ │ ├── BasicProxyBeanPostProcessor.java │ │ │ ├── PostProcessorConfig.java │ │ │ ├── Special.java │ │ │ ├── SpecialProxyBeanPostProcessor.java │ │ │ └── advice │ │ │ ├── BasicAdvice.java │ │ │ └── SpecialAdvice.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── example │ └── beanpostprocessor │ └── BeanPostProcessorApplicationTest.java ├── client-side loadbalancer ├── .gitignore ├── README.md ├── build.gradle ├── client │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── cloud │ │ │ └── loadbalancer │ │ │ ├── ClientApiController.java │ │ │ ├── ClientApplication.java │ │ │ └── config │ │ │ ├── ClientConfig.java │ │ │ ├── GreetingConfig.java │ │ │ ├── GreetingServiceInstanceListSuppler.java │ │ │ └── TargetServerProperty.java │ │ └── resources │ │ ├── META-INF │ │ └── additional-spring-configuration-metadata.json │ │ └── application.yml ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── server │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── cloud │ │ │ └── loadbalancer │ │ │ ├── ServerApiController.java │ │ │ └── ServerApplication.java │ │ └── resources │ │ └── application.yml └── settings.gradle ├── config ├── eureka.yml └── ping-client.yml ├── cookie ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── cookie │ │ │ └── demo │ │ │ ├── AtomicSequenceGenerator.java │ │ │ ├── CookieController.java │ │ │ ├── DemoApplication.java │ │ │ ├── Member.java │ │ │ ├── MemberRepository.java │ │ │ └── session │ │ │ └── SessionController.java │ └── resources │ │ ├── application.properties │ │ └── templates │ │ ├── index.html │ │ └── none.html │ └── test │ └── java │ └── com │ └── cookie │ └── demo │ └── DemoApplicationTests.java ├── defaultResponse ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── response │ │ │ ├── UseApplication.java │ │ │ ├── controllers │ │ │ └── SampleController.java │ │ │ └── dto │ │ │ ├── ResponseDto.java │ │ │ └── UserDto.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── response │ └── UseApplicationTests.java ├── elasticsearch ├── .gitignore ├── build.gradle.kts ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── request.http ├── settings.gradle.kts └── src │ ├── main │ ├── kotlin │ │ └── com │ │ │ └── bb │ │ │ └── elasticsearch │ │ │ ├── ElasticsearchApplication.kt │ │ │ ├── config │ │ │ └── ElasticsearchConfig.kt │ │ │ └── controller │ │ │ ├── IndicesController.kt │ │ │ └── IndicesDto.kt │ └── resources │ │ └── application.yaml │ └── test │ └── kotlin │ └── com │ └── bb │ └── elasticsearch │ └── ElasticsearchApplicationTests.kt ├── enable ├── .gitignore ├── README.md ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ └── main │ ├── java │ └── com │ │ └── bb │ │ ├── app │ │ ├── SomeApplication.java │ │ ├── importBeanDefinitionRegistrar │ │ │ ├── CommunicationConfigRegistrar.java │ │ │ └── EnableCommunicationUsingBeanRegistrar.java │ │ ├── importConfig │ │ │ ├── EnableJsonCommunication.java │ │ │ └── EnableProtobufCommunication.java │ │ └── importselector │ │ │ ├── CommunicationIConfigSelector.java │ │ │ └── EnableCommunicationUsingSelector.java │ │ └── common │ │ ├── JsonPayload.java │ │ ├── Payload.java │ │ ├── ProtobufPayload.java │ │ ├── config │ │ ├── JsonCommunicationConfig.java │ │ └── ProtobufCommunicationConfig.java │ │ └── service │ │ └── CommunicationService.java │ └── resources │ └── application.properties ├── encrypt-application-info ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── encrypt │ │ │ └── encrypt │ │ │ ├── EncryptApplication.java │ │ │ ├── config │ │ │ ├── DBConfiguration.java │ │ │ └── DBProperties.java │ │ │ └── controller │ │ │ └── MainController.java │ └── resources │ │ ├── application.yml │ │ └── bootstrap.yml │ └── test │ └── java │ └── com │ └── encrypt │ └── encrypt │ └── EncryptApplicationTests.java ├── etag ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── http │ └── request.http ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── lab │ │ │ └── etag │ │ │ ├── ComplexController.java │ │ │ ├── EtagApplication.java │ │ │ ├── EtagConfig.java │ │ │ ├── SampleController.java │ │ │ ├── dto │ │ │ ├── Request.java │ │ │ └── ResponseData.java │ │ │ ├── service │ │ │ └── EtagService.java │ │ │ └── utils │ │ │ └── EtagUtils.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── lab │ └── etag │ ├── ComplexControllerTest.java │ └── EtagValidateTest.java ├── github-workflow-sample └── workflows │ ├── pull-request.yml │ └── push.yml ├── githubaction-deploy ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── profile_local.gradle ├── profile_prod.gradle ├── script │ ├── deploy-event-lambda.py │ ├── local.env │ ├── prod.env │ └── start.sh ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── container │ │ │ └── auto │ │ │ ├── AutoApplication.java │ │ │ ├── config │ │ │ ├── ProfileProperty.java │ │ │ └── ServerConfig.java │ │ │ ├── handler │ │ │ └── AutoHandler.java │ │ │ └── router │ │ │ └── AutoRouter.java │ └── resources │ │ ├── application-local.yml │ │ └── application-prod.yml │ └── test │ └── java │ └── com │ └── container │ └── auto │ └── AutoApplicationTests.java ├── gradle-multi-module-master ├── .gitignore ├── README.md ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── sample-admin │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── sungjun │ │ │ │ └── admin │ │ │ │ ├── SampleAdminApplication.java │ │ │ │ └── member │ │ │ │ └── MemberController.java │ │ └── resources │ │ │ └── application.yml │ │ └── test │ │ └── java │ │ └── com │ │ └── sungjun │ │ └── admin │ │ └── SampleAdminApplicationTest.java ├── sample-api │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── sungjun │ │ │ │ └── api │ │ │ │ ├── SampleApiApplication.java │ │ │ │ └── service │ │ │ │ └── MemberServiceCustom.java │ │ └── resources │ │ │ └── application.yml │ │ └── test │ │ └── java │ │ └── com │ │ └── sungjun │ │ └── api │ │ └── service │ │ └── MemberServiceCustomTest.java ├── sample-common │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── sungjun │ │ │ └── common │ │ │ ├── member │ │ │ └── Member.java │ │ │ └── repository │ │ │ └── MemberRepository.java │ │ └── test │ │ └── java │ │ └── com │ │ └── sungjun │ │ └── common │ │ ├── ModuleCommonApplicationTests.java │ │ └── member │ │ └── MemberRepositoryTest.java └── settings.gradle ├── http ├── .gitignore ├── README.md ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── http │ ├── productGet.http │ ├── productGetCookie.http │ ├── productPost.http │ └── productPostAuthorization.http ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── test │ │ │ └── http │ │ │ ├── HttpApplication.java │ │ │ └── controller │ │ │ ├── ProductController.java │ │ │ └── dto │ │ │ └── ProductDTO.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── test │ └── http │ └── HttpApplicationTests.java ├── importOrComponentScan ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── test │ │ │ ├── componentscanconfig │ │ │ ├── ComponentScanConfigApplication.java │ │ │ ├── README.md │ │ │ ├── config │ │ │ │ ├── AnotherConfiguration.java │ │ │ │ └── CommonConfiguration.java │ │ │ └── service │ │ │ │ ├── AnotherService.java │ │ │ │ └── CommonService.java │ │ │ └── importconfig │ │ │ ├── ImportConfigApplication.java │ │ │ ├── README.md │ │ │ ├── config │ │ │ ├── AnotherConfiguration.java │ │ │ ├── AppConfiguration.java │ │ │ ├── CommonConfiguration.java │ │ │ └── OneMoreConfiguration.java │ │ │ └── service │ │ │ ├── AllNewService.java │ │ │ ├── AnotherService.java │ │ │ ├── CommonService.java │ │ │ └── OneMoreService.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── test │ └── importorcomponentscan │ └── ComponentScanConfigApplicationTests.java ├── jpa ├── jpa practices │ ├── .gitignore │ ├── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── practice │ │ │ │ └── jpa │ │ │ │ ├── JpaApplication.java │ │ │ │ ├── config │ │ │ │ └── H2ServerConfiguration.java │ │ │ │ └── domain │ │ │ │ ├── BaseTimeEntity.java │ │ │ │ ├── Comment.java │ │ │ │ ├── Member.java │ │ │ │ └── Post.java │ │ └── resources │ │ │ ├── application.yml │ │ │ └── data │ │ │ └── data.sql │ │ └── test │ │ └── java │ │ └── com │ │ └── practice │ │ └── jpa │ │ └── JpaApplicationTests.java └── spring-boot-jpa │ └── jpashop │ ├── .gitignore │ ├── build.gradle │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ ├── main │ ├── java │ │ └── jpabook │ │ │ └── jpashop │ │ │ ├── HelloController.java │ │ │ ├── JpashopApplication.java │ │ │ ├── Member.java │ │ │ └── MemberRepository.java │ └── resources │ │ ├── application.yml │ │ ├── static │ │ └── index.html │ │ └── templates │ │ └── hello.html │ └── test │ └── java │ └── jpabook │ └── jpashop │ └── MemberTest.java ├── junit5 └── tag │ ├── .gitignore │ ├── README.md │ ├── build.gradle │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── images │ ├── Untitled 1.png │ ├── Untitled 2.png │ ├── Untitled 3.png │ └── Untitled.png │ ├── settings.gradle │ └── src │ └── test │ └── java │ └── com │ └── junit5 │ └── tag │ ├── ApplicationIntegrationTests.java │ └── ApplicationUnitTests.java ├── keycloak ├── .gitignore ├── README.md ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── http │ └── request.http ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── security │ │ │ └── keycloak │ │ │ ├── KeycloakApplication.java │ │ │ ├── KeycloakConfig.java │ │ │ └── KeycloakTestController.java │ └── resources │ │ ├── application.yml │ │ └── keycloak.json │ └── test │ └── java │ └── com │ └── security │ └── keycloak │ └── KeycloakApplicationTests.java ├── log ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── test │ │ │ └── log │ │ │ ├── LogApplication.java │ │ │ ├── LogScheduler.java │ │ │ └── user │ │ │ └── LogUserScheduler.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── test │ └── log │ └── LogApplicationTests.java ├── maven └── pom.xml ├── opentelemetry └── issue-demo │ ├── HELP.md │ ├── README.md │ ├── build.gradle.kts │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle.kts │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── demo │ │ │ └── DemoApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── example │ └── demo │ └── DemoApplicationTests.java ├── prometheus ├── .gitattributes ├── .gitignore ├── README.md ├── build.gradle.kts ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts ├── src │ ├── main │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── micrometer │ │ │ │ └── prometheus │ │ │ │ ├── MetricConfig.kt │ │ │ │ ├── MetricController.kt │ │ │ │ ├── PrometheusApplication.kt │ │ │ │ └── domain │ │ │ │ ├── FooCount.kt │ │ │ │ └── FooData.kt │ │ └── resources │ │ │ └── application.yml │ └── test │ │ └── kotlin │ │ └── com │ │ └── micrometer │ │ └── prometheus │ │ └── PrometheusApplicationTests.kt └── test.http ├── property-validation ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── propertyvalidation │ │ │ ├── PropertyValidationApplication.java │ │ │ ├── ServerConfig.java │ │ │ └── ServerProperties.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── example │ └── propertyvalidation │ └── PropertyValidationApplicationTests.java ├── queue-sqs ├── .editorconfig ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── queue │ │ │ └── push │ │ │ ├── PushApplication.java │ │ │ ├── infra │ │ │ └── config │ │ │ │ ├── AwsCredentialProperty.java │ │ │ │ ├── AwsQueueConfig.java │ │ │ │ └── AwsSqsProperty.java │ │ │ └── queue │ │ │ ├── MessageReceiver.java │ │ │ └── sender │ │ │ └── SomeQueueMessageSender.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── queue │ └── push │ └── PushApplicationTests.java ├── reactor-exapnd ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── reactorexapnd │ │ │ ├── ReactorExapndTest.java │ │ │ └── domain │ │ │ ├── Post.java │ │ │ ├── PostList.java │ │ │ ├── PostListRepository.java │ │ │ └── PostListRepositoryImpl.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── example │ └── reactorexapnd │ └── ReactorExapndTestTests.java ├── reactor-webflux-testbed ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── reactor │ │ │ └── test │ │ │ ├── SomeController.java │ │ │ └── TestApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── reactor │ └── test │ ├── DeferCallableTest.java │ ├── ErrorTest.java │ └── WebClientRestTemplateCompareTest.java ├── redis ├── .gitignore ├── build.gradle ├── data │ └── .txt ├── docker-compose.yml ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── redis │ │ │ └── demo │ │ │ ├── DemoApplication.java │ │ │ ├── Member.java │ │ │ └── MemberRepository.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── redis │ └── demo │ └── RedisTest.java ├── schedule ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── test │ │ │ └── schedule │ │ │ ├── ScheduleApplication.java │ │ │ ├── config │ │ │ └── ScheduleConfiguration.java │ │ │ └── scheduler │ │ │ ├── FirstScheduler.java │ │ │ └── SecondScheduler.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── test │ └── schedule │ └── ScheduleApplicationTests.java ├── security ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── spring │ │ │ └── security │ │ │ └── SecurityApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── spring │ └── security │ └── SecurityApplicationTests.java ├── serverless ├── .gitignore ├── README.md ├── Spring Serverless.pdf ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── kimdoubleb │ │ │ └── serverless │ │ │ └── ServerlessApplication.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── kimdoubleb │ └── serverless │ └── ServerlessApplicationTests.java ├── servlet ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── hello │ │ │ └── servlet │ │ │ ├── ServletApplication.java │ │ │ ├── ServletInitializer.java │ │ │ ├── basic │ │ │ ├── HelloData.java │ │ │ ├── HelloServlet.java │ │ │ ├── request │ │ │ │ ├── RequestBodyJsonServlet.java │ │ │ │ ├── RequestBodyStringServlet.java │ │ │ │ ├── RequestHeaderServlet.java │ │ │ │ └── RequestParamServlet.java │ │ │ └── response │ │ │ │ ├── ResponseHeaderServlet.java │ │ │ │ ├── ResponseHtmlServlet.java │ │ │ │ └── ResponseJsonServlet.java │ │ │ └── domain │ │ │ └── member │ │ │ ├── Member.java │ │ │ └── MemberRepository.java │ ├── resources │ │ └── application.properties │ └── webapp │ │ ├── basic.html │ │ └── index.html │ └── test │ └── java │ └── hello │ └── servlet │ ├── ServletApplicationTests.java │ └── domain │ └── member │ └── MemberRepositoryTest.java ├── spring-cloud-example ├── .gitignore ├── README.md ├── build.gradle ├── display │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── elevenst │ │ │ ├── DisplayApplication.java │ │ │ ├── api │ │ │ └── DisplayController.java │ │ │ └── service │ │ │ ├── FeignProductRemoteService.java │ │ │ ├── FeignProductRemoteServiceFallbackFactory.java │ │ │ ├── FeignProductRemoteServiceFallbackImpl.java │ │ │ ├── ProductRemoteService.java │ │ │ └── ProductRemoteServiceImpl.java │ │ └── resources │ │ └── application.yml ├── eureka-server │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── elevenst │ │ │ └── eurekaserver │ │ │ └── EurekaServerApplication.java │ │ └── resources │ │ └── application.yml ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── product │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── elevenst │ │ │ ├── ProductApplication.java │ │ │ └── api │ │ │ └── ProductController.java │ │ └── resources │ │ └── application.yml ├── settings.gradle └── zuul │ ├── build.gradle │ └── src │ └── main │ ├── java │ └── com │ │ └── elevenst │ │ └── zuul │ │ └── ZuulApplication.java │ └── resources │ └── application.yml ├── spring-core-study ├── coreEx1-pojo │ ├── .gitignore │ ├── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── hello │ │ │ │ └── coreEx1 │ │ │ │ ├── AppConfig.java │ │ │ │ ├── CoreEx1Application.java │ │ │ │ ├── MemberApp.java │ │ │ │ ├── OrderApp.java │ │ │ │ ├── discount │ │ │ │ ├── DiscountPolicy.java │ │ │ │ ├── FixDiscountPolicy.java │ │ │ │ └── RateDiscountPolicy.java │ │ │ │ ├── member │ │ │ │ ├── Grade.java │ │ │ │ ├── Member.java │ │ │ │ ├── MemberRepository.java │ │ │ │ ├── MemberService.java │ │ │ │ ├── MemberServiceImpl.java │ │ │ │ └── MemoryMemberRepository.java │ │ │ │ └── order │ │ │ │ ├── Order.java │ │ │ │ ├── OrderService.java │ │ │ │ └── OrderServiceImpl.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── hello │ │ └── coreEx1 │ │ ├── CoreEx1ApplicationTests.java │ │ ├── discount │ │ └── RateDiscountPolicyTest.java │ │ ├── member │ │ └── MemberServiceTest.java │ │ └── order │ │ └── OrderServiceTest.java └── coreEx1-spring │ ├── .gitignore │ ├── build.gradle │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ ├── main │ ├── java │ │ └── hello │ │ │ └── coreEx1 │ │ │ ├── AppConfig.java │ │ │ ├── CoreEx1Application.java │ │ │ ├── MemberApp.java │ │ │ ├── OrderApp.java │ │ │ ├── discount │ │ │ ├── DiscountPolicy.java │ │ │ ├── FixDiscountPolicy.java │ │ │ └── RateDiscountPolicy.java │ │ │ ├── member │ │ │ ├── Grade.java │ │ │ ├── Member.java │ │ │ ├── MemberRepository.java │ │ │ ├── MemberService.java │ │ │ ├── MemberServiceImpl.java │ │ │ └── MemoryMemberRepository.java │ │ │ └── order │ │ │ ├── Order.java │ │ │ ├── OrderService.java │ │ │ └── OrderServiceImpl.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── hello │ └── coreEx1 │ ├── CoreEx1ApplicationTests.java │ ├── beanfind │ └── ApplicationContextInfoTest.java │ ├── discount │ └── RateDiscountPolicyTest.java │ ├── member │ └── MemberServiceTest.java │ └── order │ └── OrderServiceTest.java ├── springboot2-webservice ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── tistory │ │ │ └── bbdevstory │ │ │ └── springboot │ │ │ ├── Application.java │ │ │ ├── config │ │ │ ├── WebConfig.java │ │ │ └── auth │ │ │ │ ├── CustomOAuth2UserService.java │ │ │ │ ├── JpaConfig.java │ │ │ │ ├── LoginUser.java │ │ │ │ ├── LoginUserArgumentResolver.java │ │ │ │ ├── SecurityConfig.java │ │ │ │ └── dto │ │ │ │ ├── OAuthAttributes.java │ │ │ │ └── SessionUser.java │ │ │ ├── domain │ │ │ ├── BaseTimeEntity.java │ │ │ ├── posts │ │ │ │ ├── Posts.java │ │ │ │ └── PostsRepository.java │ │ │ └── user │ │ │ │ ├── Role.java │ │ │ │ ├── User.java │ │ │ │ └── UserRepository.java │ │ │ ├── service │ │ │ └── posts │ │ │ │ └── PostsService.java │ │ │ └── web │ │ │ ├── HelloController.java │ │ │ ├── IndexController.java │ │ │ ├── PostsApiController.java │ │ │ └── dto │ │ │ ├── HelloResponseDto.java │ │ │ ├── PostsListResponseDto.java │ │ │ ├── PostsResponseDto.java │ │ │ ├── PostsSaveRequestDto.java │ │ │ └── PostsUpdateRequestDto.java │ └── resources │ │ ├── application.properties │ │ ├── static │ │ └── js │ │ │ └── app │ │ │ └── index.js │ │ └── templates │ │ ├── index.mustache │ │ ├── layout │ │ ├── footer.mustache │ │ └── header.mustache │ │ ├── posts-save.mustache │ │ └── posts-update.mustache │ └── test │ ├── java │ └── com │ │ └── tistory │ │ └── bbdevstory │ │ └── springboot │ │ └── web │ │ ├── HelloControllerTest.java │ │ ├── IndexControllerTest.java │ │ ├── PostsApiControllerTest.java │ │ ├── domain │ │ └── posts │ │ │ └── PostsRepositoryTest.java │ │ └── dto │ │ └── HelloResponseDtoTest.java │ └── resources │ └── application.properties ├── webclient ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ └── main │ ├── java │ └── com │ │ └── practice │ │ └── webclient │ │ ├── WebclientApplication.java │ │ └── jsonplace │ │ ├── config │ │ ├── WebClientConfig.java │ │ └── WebClientProperty.java │ │ ├── dto │ │ ├── JsonPlaceResponse.java │ │ └── UserPostResponse.java │ │ └── service │ │ └── JsonPlaceWebClient.java │ └── resources │ └── application.yaml └── webflux-r2dbc-mysql ├── .gitignore ├── build.gradle ├── docker ├── data │ └── init.sql └── docker-compose.yaml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src ├── main ├── java │ └── com │ │ └── example │ │ └── demo │ │ ├── DemoApplication.java │ │ ├── application │ │ ├── PostService.java │ │ ├── UserService.java │ │ └── dto │ │ │ ├── PostResponse.java │ │ │ ├── PostResponseWithUser.java │ │ │ ├── SavePostRequest.java │ │ │ └── UserResponse.java │ │ ├── config │ │ └── R2dbcConfig.java │ │ ├── controller │ │ ├── PostController.java │ │ └── UserController.java │ │ └── domain │ │ ├── post │ │ ├── Post.java │ │ ├── PostCustomRepository.java │ │ ├── PostCustomRepositoryImpl.java │ │ ├── PostRepository.java │ │ ├── PostUserSpecificInfo.java │ │ └── converter │ │ │ └── PostReadConverter.java │ │ └── user │ │ ├── User.java │ │ ├── UserCustomRepository.java │ │ ├── UserCustomRepositoryImpl.java │ │ └── UserRepository.java └── resources │ └── application.yml └── test └── java └── com └── example └── demo ├── DemoApplicationTests.java └── domain └── user └── UserCustomRepositoryImplTest.java /.gitattributes: -------------------------------------------------------------------------------- 1 | *.css linguist-detectable=false 2 | *.js linguist-detectable=false 3 | *.html linguist-detectable=false -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spring 탐험 저장소 2 | 3 | Spring의 이곳 저곳을 살펴보자. 4 | 그리고 배워나가자. 5 | 6 | ![spring](https://media.giphy.com/media/8hPZhEi1MgHPq/giphy.gif) 7 | 8 | 틀린 것들 또는 보완할 점들이 있다면, 이슈 부탁드립니다. 9 | -------------------------------------------------------------------------------- /api-versioning/.gitattributes: -------------------------------------------------------------------------------- 1 | /gradlew text eol=lf 2 | *.bat text eol=crlf 3 | *.jar binary 4 | -------------------------------------------------------------------------------- /api-versioning/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /api-versioning/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/api-versioning/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /api-versioning/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /api-versioning/http/request-error.http: -------------------------------------------------------------------------------- 1 | ### URI - version 3 2 | GET localhost:8080/api/uri/v3/versions 3 | 4 | ### request parameter - version 3 5 | GET localhost:8080/api/parameter/versions?version=3 6 | 7 | ### header - version 1 8 | GET localhost:8080/api/header/versions 9 | X-API-Version: 3 10 | -------------------------------------------------------------------------------- /api-versioning/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { url = uri("https://repo.spring.io/milestone") } 4 | maven { url = uri("https://repo.spring.io/snapshot") } 5 | gradlePluginPortal() 6 | } 7 | } 8 | rootProject.name = "api" 9 | -------------------------------------------------------------------------------- /api-versioning/src/main/java/com/version/api/ApiApplication.java: -------------------------------------------------------------------------------- 1 | package com.version.api; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ApiApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ApiApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /api-versioning/src/main/java/com/version/api/config/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package com.version.api.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.ApiVersionConfigurer; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | @Configuration 8 | public class WebMvcConfig implements WebMvcConfigurer { 9 | 10 | @Override 11 | public void configureApiVersioning(ApiVersionConfigurer configurer) { 12 | configurer 13 | .useRequestParam("version") 14 | .useRequestHeader("X-API-Version") 15 | .setDefaultVersion("1.0.0") 16 | .addSupportedVersions("1.0.0", "2.0.0") 17 | .setVersionRequired(true); 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /api-versioning/src/main/java/com/version/api/controller/uri/UriVersionControllerV1.java: -------------------------------------------------------------------------------- 1 | package com.version.api.controller.uri; 2 | 3 | import org.springframework.http.ResponseEntity; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import java.util.List; 9 | 10 | @RestController 11 | @RequestMapping("/api/uri/v1") 12 | public class UriVersionControllerV1 { 13 | 14 | @GetMapping("/versions") 15 | public ResponseEntity> getVersions() { 16 | return ResponseEntity.ok(List.of("v1.1", "v1.2", "v1.3")); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /api-versioning/src/main/java/com/version/api/controller/uri/UriVersionControllerV2.java: -------------------------------------------------------------------------------- 1 | package com.version.api.controller.uri; 2 | 3 | import org.springframework.http.ResponseEntity; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import java.util.List; 9 | 10 | @RestController 11 | @RequestMapping("/api/uri/v2") 12 | public class UriVersionControllerV2 { 13 | 14 | @GetMapping("/versions") 15 | public ResponseEntity> getVersions() { 16 | return ResponseEntity.ok(List.of("v2.1", "v2.2", "v2.3")); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /api-versioning/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: api-versioning 4 | 5 | server: 6 | port: 8080 7 | 8 | -------------------------------------------------------------------------------- /api-versioning/src/test/java/com/version/api/ApiApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.version.api; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ApiApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /argument-resolver/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /argument-resolver/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.7.1' 3 | id 'io.spring.dependency-management' version '1.0.11.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'com.argument.resolver' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '17' 10 | 11 | configurations { 12 | compileOnly { 13 | extendsFrom annotationProcessor 14 | } 15 | } 16 | 17 | repositories { 18 | mavenCentral() 19 | } 20 | 21 | dependencies { 22 | implementation 'org.springframework.boot:spring-boot-starter-web' 23 | compileOnly 'org.projectlombok:lombok' 24 | annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' 25 | annotationProcessor 'org.projectlombok:lombok' 26 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 27 | } 28 | 29 | tasks.named('test') { 30 | useJUnitPlatform() 31 | } 32 | -------------------------------------------------------------------------------- /argument-resolver/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/argument-resolver/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /argument-resolver/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /argument-resolver/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'resolver' 2 | -------------------------------------------------------------------------------- /argument-resolver/src/main/java/com/argument/resolver/ResolverApplication.java: -------------------------------------------------------------------------------- 1 | package com.argument.resolver; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ResolverApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ResolverApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /argument-resolver/src/main/java/com/argument/resolver/api/Person.java: -------------------------------------------------------------------------------- 1 | package com.argument.resolver.api; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Person { 7 | 8 | private final String name; 9 | private final int age; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /argument-resolver/src/main/java/com/argument/resolver/api/TestController.java: -------------------------------------------------------------------------------- 1 | package com.argument.resolver.api; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.http.ResponseEntity; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | @RestController 11 | @RequestMapping("/v1/test") 12 | @RequiredArgsConstructor 13 | @Slf4j 14 | public class TestController { 15 | 16 | @GetMapping 17 | public ResponseEntity test(Person person) { 18 | log.info("Person {}", person); 19 | return ResponseEntity.ok().build(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /argument-resolver/src/main/java/com/argument/resolver/config/WebConfigurer.java: -------------------------------------------------------------------------------- 1 | package com.argument.resolver.config; 2 | 3 | import com.argument.resolver.api.resolver.PersonArgumentResolver; 4 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | import java.util.List; 8 | 9 | public class WebConfigurer implements WebMvcConfigurer { 10 | 11 | @Override 12 | public void addArgumentResolvers(List resolvers) { 13 | resolvers.add(new PersonArgumentResolver()); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /argument-resolver/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /argument-resolver/src/test/java/com/argument/resolver/resolver/ResolverApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.argument.resolver.resolver; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ResolverApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /auth0-integration/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/auth0-integration/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /auth0-integration/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /auth0-integration/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "demo" 2 | -------------------------------------------------------------------------------- /auth0-integration/src/main/java/com/oauth0/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.oauth0.demo; 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 | -------------------------------------------------------------------------------- /auth0-integration/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | security: 3 | oauth2: 4 | client: 5 | registration: 6 | auth0: 7 | client-id: ${CLIENT_ID} 8 | client-secret: ${CLIENT_SECRET} 9 | scope: 10 | - openid 11 | - profile 12 | - email 13 | provider: 14 | auth0: 15 | # trailing slash is important! 16 | issuer-uri: ${AUTH0_ISSUER_URI} 17 | -------------------------------------------------------------------------------- /auth0-integration/src/test/java/com/oauth0/demo/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.oauth0.demo; 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 | -------------------------------------------------------------------------------- /bean-post-processor/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /bean-post-processor/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/bean-post-processor/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /bean-post-processor/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /bean-post-processor/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'bean-post-processor' 2 | -------------------------------------------------------------------------------- /bean-post-processor/src/main/java/com/example/beanpostprocessor/BeanPostProcessorApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.beanpostprocessor; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.springframework.boot.CommandLineRunner; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | 8 | @SpringBootApplication 9 | @RequiredArgsConstructor 10 | public class BeanPostProcessorApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(BeanPostProcessorApplication.class, args); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /bean-post-processor/src/main/java/com/example/beanpostprocessor/special/Special.java: -------------------------------------------------------------------------------- 1 | package com.example.beanpostprocessor.special; 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 Special { 11 | } 12 | -------------------------------------------------------------------------------- /bean-post-processor/src/main/java/com/example/beanpostprocessor/special/advice/BasicAdvice.java: -------------------------------------------------------------------------------- 1 | package com.example.beanpostprocessor.special.advice; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.aopalliance.intercept.MethodInterceptor; 5 | import org.aopalliance.intercept.MethodInvocation; 6 | 7 | @Slf4j 8 | public class BasicAdvice implements MethodInterceptor { 9 | 10 | @Override 11 | public Object invoke(MethodInvocation invocation) throws Throwable { 12 | log.info("[Basic Advice] 실행"); 13 | Object result = invocation.proceed(); 14 | log.info("[Basic Advice] 종료"); 15 | return result; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /bean-post-processor/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /client-side loadbalancer/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /client-side loadbalancer/client/build.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | springCloudVersion = '2021.0.0' 3 | } 4 | 5 | dependencies { 6 | implementation 'org.springframework.cloud:spring-cloud-starter-loadbalancer' 7 | } 8 | 9 | dependencyManagement { 10 | imports { 11 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" 12 | } 13 | } -------------------------------------------------------------------------------- /client-side loadbalancer/client/src/main/java/com/cloud/loadbalancer/ClientApplication.java: -------------------------------------------------------------------------------- 1 | package com.cloud.loadbalancer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ClientApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ClientApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /client-side loadbalancer/client/src/main/java/com/cloud/loadbalancer/config/ClientConfig.java: -------------------------------------------------------------------------------- 1 | package com.cloud.loadbalancer.config; 2 | 3 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 4 | import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.reactive.function.client.WebClient; 8 | 9 | @Configuration 10 | @LoadBalancerClient(name = "doubleb-server", configuration = GreetingConfig.class) 11 | public class ClientConfig { 12 | 13 | @LoadBalanced 14 | @Bean 15 | public WebClient.Builder loadbalancerClient() { 16 | return WebClient.builder(); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /client-side loadbalancer/client/src/main/java/com/cloud/loadbalancer/config/GreetingConfig.java: -------------------------------------------------------------------------------- 1 | package com.cloud.loadbalancer.config; 2 | 3 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 4 | import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.context.annotation.Primary; 8 | 9 | @Configuration 10 | @EnableConfigurationProperties(TargetServerProperty.class) 11 | public class GreetingConfig { 12 | 13 | @Bean 14 | @Primary 15 | ServiceInstanceListSupplier serviceInstanceListSupplier(TargetServerProperty serverProperty) { 16 | return new GreetingServiceInstanceListSuppler("doubleb-server", serverProperty); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /client-side loadbalancer/client/src/main/java/com/cloud/loadbalancer/config/TargetServerProperty.java: -------------------------------------------------------------------------------- 1 | package com.cloud.loadbalancer.config; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | 7 | import java.util.List; 8 | 9 | @ConfigurationProperties(prefix = "target") 10 | @Getter @Setter 11 | public class TargetServerProperty { 12 | 13 | private List servers; 14 | 15 | 16 | @Getter @Setter 17 | public static class Server { 18 | 19 | private String host; 20 | private Integer port; 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /client-side loadbalancer/client/src/main/resources/META-INF/additional-spring-configuration-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": [ 3 | { 4 | "name": "target.servers", 5 | "type": "java.lang.String", 6 | "description": "target servers for client load balancing." 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /client-side loadbalancer/client/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | target: 2 | servers: 3 | - host: "localhost" 4 | port: 8081 5 | - host: "localhost" 6 | port: 8082 7 | - host: "localhost" 8 | port: 8083 -------------------------------------------------------------------------------- /client-side loadbalancer/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/client-side loadbalancer/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /client-side loadbalancer/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /client-side loadbalancer/server/build.gradle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/client-side loadbalancer/server/build.gradle -------------------------------------------------------------------------------- /client-side loadbalancer/server/src/main/java/com/cloud/loadbalancer/ServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.cloud.loadbalancer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ServerApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ServerApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /client-side loadbalancer/server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: doubleb-server 4 | 5 | server: 6 | port: ${SERVER_PORT} 7 | -------------------------------------------------------------------------------- /client-side loadbalancer/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'loadbalancer' 2 | include 'client' 3 | include 'server' -------------------------------------------------------------------------------- /config/eureka.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | client: 3 | register-with-eureka: false 4 | fetch-registry: false 5 | service-url: 6 | defaultZone: eureka.default.svc.cluster.local:8761 7 | 8 | server: 9 | response-cache-update-interval-ms: 1000 10 | eviction-interval-timer-in-ms: 30000 # default 60000 11 | defaultOpenForTrafficCount: 0 # default 1. set 0 for warm up mode 12 | -------------------------------------------------------------------------------- /config/ping-client.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | instance: 3 | prefer-ip-address: true # IP 주소 등록 4 | client: 5 | register-with-eureka: true 6 | fetch-registry: false 7 | service-url: 8 | defaultZone: eureka.default.svc.cluster.local:8761 -------------------------------------------------------------------------------- /cookie/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /cookie/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.5.3' 3 | id 'io.spring.dependency-management' version '1.0.11.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'com.cookie' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '11' 10 | 11 | configurations { 12 | compileOnly { 13 | extendsFrom annotationProcessor 14 | } 15 | } 16 | 17 | repositories { 18 | mavenCentral() 19 | } 20 | 21 | dependencies { 22 | implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' 23 | implementation 'org.springframework.boot:spring-boot-starter-web' 24 | compileOnly 'org.projectlombok:lombok' 25 | annotationProcessor 'org.projectlombok:lombok' 26 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 27 | } 28 | 29 | test { 30 | useJUnitPlatform() 31 | } 32 | -------------------------------------------------------------------------------- /cookie/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/cookie/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /cookie/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /cookie/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'demo' 2 | -------------------------------------------------------------------------------- /cookie/src/main/java/com/cookie/demo/AtomicSequenceGenerator.java: -------------------------------------------------------------------------------- 1 | package com.cookie.demo; 2 | 3 | import java.util.concurrent.atomic.AtomicLong; 4 | 5 | public class AtomicSequenceGenerator { 6 | 7 | private AtomicLong value = new AtomicLong(1); 8 | 9 | public long getNext() { 10 | return value.getAndIncrement(); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /cookie/src/main/java/com/cookie/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.cookie.demo; 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 | -------------------------------------------------------------------------------- /cookie/src/main/java/com/cookie/demo/Member.java: -------------------------------------------------------------------------------- 1 | package com.cookie.demo; 2 | 3 | public class Member { 4 | public static final String KEY = "member"; 5 | private final Long memberId; 6 | private final String name; 7 | 8 | private Member(Long memberId, String name) { 9 | this.memberId = memberId; 10 | this.name = name; 11 | } 12 | 13 | public static Member create(Long memberId, String name) { 14 | return new Member(memberId, name); 15 | } 16 | 17 | public Long getMemberId() { 18 | return memberId; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /cookie/src/main/java/com/cookie/demo/MemberRepository.java: -------------------------------------------------------------------------------- 1 | package com.cookie.demo; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import java.util.Map; 6 | import java.util.concurrent.ConcurrentHashMap; 7 | 8 | @Repository 9 | public class MemberRepository { 10 | 11 | Map members = new ConcurrentHashMap<>(); 12 | 13 | public void save(Member member) { 14 | members.put(member.getMemberId(), member); 15 | } 16 | 17 | public Member findById(Long id) { 18 | return members.get(id); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /cookie/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /cookie/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | Cookie Test 9 | 10 | 11 |

12 | cookie ! 13 |

14 |

15 | no cookie ! 16 |

17 | 18 |
19 |
20 |
21 | 22 |

Your request header

23 | 24 | 25 | 26 | 27 | 28 | 29 |
Key 1:Value 1
30 | 31 | -------------------------------------------------------------------------------- /cookie/src/main/resources/templates/none.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | None page 9 | 10 | 11 |

"HELLO"

12 |
13 |

Your request header

14 | 15 | 16 | 17 | 18 | 19 | 20 |
Key 1:Value 1
21 | 22 | -------------------------------------------------------------------------------- /cookie/src/test/java/com/cookie/demo/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.cookie.demo; 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 | -------------------------------------------------------------------------------- /defaultResponse/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /defaultResponse/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/defaultResponse/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /defaultResponse/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /defaultResponse/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'use' 2 | -------------------------------------------------------------------------------- /defaultResponse/src/main/java/com/response/UseApplication.java: -------------------------------------------------------------------------------- 1 | package com.response; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class UseApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(UseApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /defaultResponse/src/main/java/com/response/dto/UserDto.java: -------------------------------------------------------------------------------- 1 | package com.response.dto; 2 | 3 | public class UserDto { 4 | private final String id; 5 | private final String name; 6 | private final int age; 7 | 8 | public UserDto(String id, String name, int age) { 9 | this.id = id; 10 | this.name = name; 11 | this.age = age; 12 | } 13 | 14 | public String getId() { 15 | return id; 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /defaultResponse/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /defaultResponse/src/test/java/com/response/UseApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.response; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class UseApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /elasticsearch/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /elasticsearch/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/elasticsearch/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /elasticsearch/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /elasticsearch/request.http: -------------------------------------------------------------------------------- 1 | ### Indices 생성 2 | POST localhost:8080/api/v1/indices 3 | Content-Type: application/json 4 | 5 | { 6 | "name": "test" 7 | } 8 | 9 | ### -------------------------------------------------------------------------------- /elasticsearch/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "elasticsearch" 2 | -------------------------------------------------------------------------------- /elasticsearch/src/main/kotlin/com/bb/elasticsearch/ElasticsearchApplication.kt: -------------------------------------------------------------------------------- 1 | package com.bb.elasticsearch 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication 4 | import org.springframework.boot.runApplication 5 | 6 | @SpringBootApplication 7 | class ElasticsearchApplication 8 | 9 | fun main(args: Array) { 10 | runApplication(*args) 11 | } 12 | -------------------------------------------------------------------------------- /elasticsearch/src/main/kotlin/com/bb/elasticsearch/controller/IndicesDto.kt: -------------------------------------------------------------------------------- 1 | package com.bb.elasticsearch.controller 2 | 3 | data class CreateIndicesRequest(val name: String) -------------------------------------------------------------------------------- /elasticsearch/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | elasticsearch: 2 | server-url: http://localhost:9200 3 | -------------------------------------------------------------------------------- /elasticsearch/src/test/kotlin/com/bb/elasticsearch/ElasticsearchApplicationTests.kt: -------------------------------------------------------------------------------- 1 | package com.bb.elasticsearch 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.springframework.boot.test.context.SpringBootTest 5 | 6 | @SpringBootTest 7 | class ElasticsearchApplicationTests { 8 | 9 | @Test 10 | fun contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /enable/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /enable/README.md: -------------------------------------------------------------------------------- 1 | # Enable annotation 2 | 3 | 여러 Spring 외부 모듈을 사용하다보면 `@Enable ~` 어노테이션을 활용해 외무 모듈 기능을 활성화하는 경우가 있다. 4 | 5 | 이들이 어떻게 이루어지고, 어떻게 사용되는지 알아보자. 6 | 7 | - `@Import`를 통해 Configuration class를 등록하여 활성화 시키는 방법 8 | - `com.bb.app.importConfig` 패키지 참조 9 | - `@Import`를 통해 ImportSelector를 구현한 class를 등록하여 활성화 시키는 방법 10 | - `com.bb.app.importselector` 패키지 참조 11 | - `@Import`를 통해 ImportBeanDefinitionRegistrar를 구현한 class를 등록하여 활성화 시키는 방법 12 | - `com.bb.app.importBeanDefinitionRegistrar` 패키지 참조 -------------------------------------------------------------------------------- /enable/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.6.1' 3 | id 'io.spring.dependency-management' version '1.0.11.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'com.bb' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '17' 10 | 11 | configurations { 12 | compileOnly { 13 | extendsFrom annotationProcessor 14 | } 15 | } 16 | 17 | repositories { 18 | mavenCentral() 19 | } 20 | 21 | dependencies { 22 | implementation 'org.springframework.boot:spring-boot-starter-web' 23 | compileOnly 'org.projectlombok:lombok' 24 | annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' 25 | annotationProcessor 'org.projectlombok:lombok' 26 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 27 | } 28 | 29 | test { 30 | useJUnitPlatform() 31 | } 32 | -------------------------------------------------------------------------------- /enable/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/enable/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /enable/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /enable/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'enable' 2 | -------------------------------------------------------------------------------- /enable/src/main/java/com/bb/app/importBeanDefinitionRegistrar/EnableCommunicationUsingBeanRegistrar.java: -------------------------------------------------------------------------------- 1 | package com.bb.app.importBeanDefinitionRegistrar; 2 | 3 | import com.bb.common.Payload.Type; 4 | import org.springframework.context.annotation.Import; 5 | 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Retention; 8 | import java.lang.annotation.RetentionPolicy; 9 | import java.lang.annotation.Target; 10 | 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.TYPE) 13 | @Import(CommunicationConfigRegistrar.class) 14 | public @interface EnableCommunicationUsingBeanRegistrar { 15 | 16 | Type type() default Type.JSON; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /enable/src/main/java/com/bb/app/importConfig/EnableJsonCommunication.java: -------------------------------------------------------------------------------- 1 | package com.bb.app.importConfig; 2 | 3 | import com.bb.common.config.JsonCommunicationConfig; 4 | import org.springframework.context.annotation.Import; 5 | 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Retention; 8 | import java.lang.annotation.RetentionPolicy; 9 | import java.lang.annotation.Target; 10 | 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.TYPE) 13 | @Import(JsonCommunicationConfig.class) 14 | public @interface EnableJsonCommunication { 15 | } 16 | -------------------------------------------------------------------------------- /enable/src/main/java/com/bb/app/importConfig/EnableProtobufCommunication.java: -------------------------------------------------------------------------------- 1 | package com.bb.app.importConfig; 2 | 3 | import com.bb.common.config.ProtobufCommunicationConfig; 4 | import org.springframework.context.annotation.Import; 5 | 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Retention; 8 | import java.lang.annotation.RetentionPolicy; 9 | import java.lang.annotation.Target; 10 | 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.TYPE) 13 | @Import(ProtobufCommunicationConfig.class) 14 | public @interface EnableProtobufCommunication { 15 | } 16 | -------------------------------------------------------------------------------- /enable/src/main/java/com/bb/app/importselector/EnableCommunicationUsingSelector.java: -------------------------------------------------------------------------------- 1 | package com.bb.app.importselector; 2 | 3 | import com.bb.common.Payload.Type; 4 | import org.springframework.context.annotation.Import; 5 | 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Retention; 8 | import java.lang.annotation.RetentionPolicy; 9 | import java.lang.annotation.Target; 10 | 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.TYPE) 13 | @Import(CommunicationIConfigSelector.class) 14 | public @interface EnableCommunicationUsingSelector { 15 | 16 | Type type() default Type.JSON; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /enable/src/main/java/com/bb/common/JsonPayload.java: -------------------------------------------------------------------------------- 1 | package com.bb.common; 2 | 3 | public class JsonPayload implements Payload { 4 | } 5 | -------------------------------------------------------------------------------- /enable/src/main/java/com/bb/common/Payload.java: -------------------------------------------------------------------------------- 1 | package com.bb.common; 2 | 3 | public interface Payload { 4 | 5 | enum Type { 6 | JSON, 7 | PROTOBUF 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /enable/src/main/java/com/bb/common/ProtobufPayload.java: -------------------------------------------------------------------------------- 1 | package com.bb.common; 2 | 3 | public class ProtobufPayload implements Payload { 4 | } 5 | -------------------------------------------------------------------------------- /enable/src/main/java/com/bb/common/config/JsonCommunicationConfig.java: -------------------------------------------------------------------------------- 1 | package com.bb.common.config; 2 | 3 | import com.bb.common.JsonPayload; 4 | import com.bb.common.service.CommunicationService; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | @Slf4j 10 | @Configuration 11 | public class JsonCommunicationConfig { 12 | 13 | @Bean 14 | public CommunicationService communicationService() { 15 | log.info("Register JsonPayload to CommunicationService"); 16 | return new CommunicationService(new JsonPayload()); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /enable/src/main/java/com/bb/common/config/ProtobufCommunicationConfig.java: -------------------------------------------------------------------------------- 1 | package com.bb.common.config; 2 | 3 | import com.bb.common.ProtobufPayload; 4 | import com.bb.common.service.CommunicationService; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | @Slf4j 10 | @Configuration 11 | public class ProtobufCommunicationConfig { 12 | 13 | @Bean 14 | public CommunicationService communicationService() { 15 | log.info("Register ProtobufPayload to CommunicationService"); 16 | return new CommunicationService(new ProtobufPayload()); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /enable/src/main/java/com/bb/common/service/CommunicationService.java: -------------------------------------------------------------------------------- 1 | package com.bb.common.service; 2 | 3 | import com.bb.common.Payload; 4 | import org.springframework.stereotype.Service; 5 | 6 | @Service 7 | public class CommunicationService { 8 | 9 | private final Payload payload; 10 | 11 | public CommunicationService(Payload payload) { 12 | this.payload = payload; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /enable/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /encrypt-application-info/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /encrypt-application-info/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/encrypt-application-info/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /encrypt-application-info/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /encrypt-application-info/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'encrypt' 2 | -------------------------------------------------------------------------------- /encrypt-application-info/src/main/java/com/encrypt/encrypt/EncryptApplication.java: -------------------------------------------------------------------------------- 1 | package com.encrypt.encrypt; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class EncryptApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(EncryptApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /encrypt-application-info/src/main/java/com/encrypt/encrypt/config/DBConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.encrypt.encrypt.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Data 9 | @Configuration 10 | @EnableConfigurationProperties(DBProperties.class) 11 | public class DBConfiguration { 12 | DBProperties dbProperties; 13 | 14 | public DBConfiguration(DBProperties dbProperties) { 15 | this.dbProperties = dbProperties; 16 | } 17 | } -------------------------------------------------------------------------------- /encrypt-application-info/src/main/java/com/encrypt/encrypt/config/DBProperties.java: -------------------------------------------------------------------------------- 1 | package com.encrypt.encrypt.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | 6 | @Data 7 | @ConfigurationProperties(prefix = "db") 8 | public class DBProperties { 9 | private String driver; 10 | private String url; 11 | private String username; 12 | private String password; 13 | } 14 | -------------------------------------------------------------------------------- /encrypt-application-info/src/main/java/com/encrypt/encrypt/controller/MainController.java: -------------------------------------------------------------------------------- 1 | package com.encrypt.encrypt.controller; 2 | 3 | import com.encrypt.encrypt.config.DBConfiguration; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | 9 | @Controller 10 | @RequestMapping("/") 11 | public class MainController { 12 | 13 | final DBConfiguration dbConfiguration; 14 | 15 | public MainController(DBConfiguration dbConfiguration) { 16 | this.dbConfiguration = dbConfiguration; 17 | } 18 | 19 | @GetMapping("") 20 | @ResponseBody 21 | public String test(){ 22 | return dbConfiguration.toString(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /encrypt-application-info/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | db: 2 | driver: 'com.jdbc.Driver' 3 | url: 'jdbc:mysql:/127.0.0.1:3306' 4 | username: '{cipher}cc4c6d4fd5ce31f30359c611f8740dfea7a3e83ecfa006209ec311dea10d05b5' 5 | password: '{cipher}d2523c4b5b679da9dbec278542ca8185a5e56673201621f61946cb0431c5e607' -------------------------------------------------------------------------------- /encrypt-application-info/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | encrypt: 2 | key: key -------------------------------------------------------------------------------- /encrypt-application-info/src/test/java/com/encrypt/encrypt/EncryptApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.encrypt.encrypt; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class EncryptApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /etag/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /etag/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id 'org.springframework.boot' version '3.0.4' 4 | id 'io.spring.dependency-management' version '1.1.0' 5 | } 6 | 7 | group = 'com.lab' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '17' 10 | 11 | configurations { 12 | compileOnly { 13 | extendsFrom annotationProcessor 14 | } 15 | } 16 | 17 | repositories { 18 | mavenCentral() 19 | } 20 | 21 | dependencies { 22 | implementation 'org.springframework.boot:spring-boot-starter-web' 23 | compileOnly 'org.projectlombok:lombok' 24 | annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' 25 | annotationProcessor 'org.projectlombok:lombok' 26 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 27 | } 28 | 29 | tasks.named('test') { 30 | useJUnitPlatform() 31 | } 32 | -------------------------------------------------------------------------------- /etag/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/etag/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /etag/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /etag/http/request.http: -------------------------------------------------------------------------------- 1 | GET localhost:8080/sample/no-etag 2 | 3 | ### 4 | GET localhost:8080/sample/etag/1 5 | 6 | > {% 7 | client.global.set("EtagValue", response.headers.valueOf("ETag")); 8 | %} 9 | ### 10 | GET localhost:8080/sample/etag/2 11 | 12 | > {% 13 | client.global.set("EtagValue", response.headers.valueOf("ETag")); 14 | %} 15 | ### 16 | PUT localhost:8080/sample/etag/1 17 | If-Match: {{EtagValue}} 18 | 19 | ### 20 | PUT localhost:8080/sample/etag/2 21 | If-Match: {{EtagValue}} 22 | 23 | ### 24 | # 분마다 ETag가 변경된다 25 | GET localhost:8080/sample/etag/minute 26 | 27 | > {% 28 | client.global.set("EtagValue", response.headers.valueOf("ETag")); 29 | %} 30 | 31 | ### ETag 사용한 request 32 | GET localhost:8080/sample/etag/minute 33 | If-None-Match: {{EtagValue}} 34 | -------------------------------------------------------------------------------- /etag/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'etag' 2 | -------------------------------------------------------------------------------- /etag/src/main/java/com/lab/etag/EtagApplication.java: -------------------------------------------------------------------------------- 1 | package com.lab.etag; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class EtagApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(EtagApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /etag/src/main/java/com/lab/etag/EtagConfig.java: -------------------------------------------------------------------------------- 1 | package com.lab.etag; 2 | 3 | import org.springframework.boot.web.servlet.FilterRegistrationBean; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.filter.ShallowEtagHeaderFilter; 7 | 8 | @Configuration 9 | public class EtagConfig { 10 | 11 | @Bean 12 | public FilterRegistrationBean shallowEtagHeaderFilter() { 13 | var shallowEtagHeaderFilter = new FilterRegistrationBean<>(new ShallowEtagHeaderFilter()); 14 | shallowEtagHeaderFilter.addUrlPatterns("/sample/etag/*"); 15 | return shallowEtagHeaderFilter; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /etag/src/main/java/com/lab/etag/dto/Request.java: -------------------------------------------------------------------------------- 1 | package com.lab.etag.dto; 2 | 3 | public record Request(String name, Integer age) { 4 | } 5 | -------------------------------------------------------------------------------- /etag/src/main/java/com/lab/etag/dto/ResponseData.java: -------------------------------------------------------------------------------- 1 | package com.lab.etag.dto; 2 | 3 | public record ResponseData(String name, Integer age) { 4 | } 5 | -------------------------------------------------------------------------------- /etag/src/main/java/com/lab/etag/utils/EtagUtils.java: -------------------------------------------------------------------------------- 1 | package com.lab.etag.utils; 2 | 3 | import org.springframework.util.DigestUtils; 4 | 5 | import com.lab.etag.dto.ResponseData; 6 | 7 | public class EtagUtils { 8 | 9 | private EtagUtils() { 10 | } 11 | 12 | public static String generateETagHeaderValue(ResponseData responseData) { 13 | return generateETagHeaderValue(responseData.toString()); 14 | } 15 | 16 | /* 17 | ShallowEtagHeaderFilter 메서드 참조 18 | */ 19 | public static String generateETagHeaderValue(String input) { 20 | // length of W/ + " + 0 + 32bits md5 hash + " 21 | var builder = new StringBuilder(37); 22 | builder.append("\"0"); 23 | DigestUtils.appendMd5DigestAsHex(input.getBytes(), builder); 24 | builder.append('"'); 25 | return builder.toString(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /etag/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /githubaction-deploy/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /githubaction-deploy/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/githubaction-deploy/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /githubaction-deploy/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /githubaction-deploy/profile_local.gradle: -------------------------------------------------------------------------------- 1 | jib { 2 | to { 3 | // TODO: 환경변수 이용 4 | image = "123220671310.dkr.ecr.ap-northeast-2.amazonaws.com/auto-github-action-deploy" 5 | tags = ["local-" + System.currentTimeMillis()] 6 | } 7 | container { 8 | // Set JVM options. 9 | jvmFlags = ['-Dspring.profiles.active=local', '-XX:+UseContainerSupport', 10 | '-Dserver.port=8081', '-Dfile.encoding=UTF-8'] 11 | // Expose different port. 12 | ports = ['8081'] 13 | user = "nobody:nogroup" 14 | } 15 | } -------------------------------------------------------------------------------- /githubaction-deploy/profile_prod.gradle: -------------------------------------------------------------------------------- 1 | jib { 2 | to { 3 | // TODO: 환경변수 이용 4 | image = "123220671310.dkr.ecr.ap-northeast-2.amazonaws.com/auto-github-action-deploy" 5 | tags = ["latest", "prod-" + System.currentTimeMillis()] 6 | } 7 | container { 8 | // Set JVM options. 9 | jvmFlags = ['-Dspring.profiles.active=prod', '-XX:+UseContainerSupport', 10 | '-Dserver.port=8080', '-Dfile.encoding=UTF-8'] 11 | // Expose different port. 12 | ports = ['8080'] 13 | user = "nobody:nogroup" 14 | } 15 | } -------------------------------------------------------------------------------- /githubaction-deploy/script/local.env: -------------------------------------------------------------------------------- 1 | LOCAL_PROFILE=local -------------------------------------------------------------------------------- /githubaction-deploy/script/prod.env: -------------------------------------------------------------------------------- 1 | PROD_PROFILE=prod -------------------------------------------------------------------------------- /githubaction-deploy/script/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # parameters 4 | containerImage=$1 5 | containerTag=$2 6 | 7 | # if latset tag, finish 8 | if [ $containerTag = "latest" ] 9 | then 10 | exit 0 11 | fi 12 | 13 | profile=`echo "$containerTag" | awk -F- '{ print $1 }'` 14 | containerId=`docker ps | grep "$containerImage:$profile" | awk '{ print $1 }'` 15 | env="/home/ec2-user/github-action/$profile.env" 16 | 17 | # set port 18 | port=8080 19 | if [ $profile = "local" ] 20 | then 21 | port=8081 22 | fi 23 | 24 | # stop container 25 | if [ ! -z "$containerId" ] 26 | then 27 | docker stop $containerId 28 | fi 29 | 30 | # start container 31 | docker run -d -p $port:$port --env-file $env $containerImage:$containerTag -------------------------------------------------------------------------------- /githubaction-deploy/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'auto' 2 | -------------------------------------------------------------------------------- /githubaction-deploy/src/main/java/com/container/auto/AutoApplication.java: -------------------------------------------------------------------------------- 1 | package com.container.auto; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class AutoApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(AutoApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /githubaction-deploy/src/main/java/com/container/auto/config/ProfileProperty.java: -------------------------------------------------------------------------------- 1 | package com.container.auto.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | @ConfigurationProperties(prefix = "server") 6 | public record ProfileProperty(String profile) { 7 | } 8 | -------------------------------------------------------------------------------- /githubaction-deploy/src/main/java/com/container/auto/config/ServerConfig.java: -------------------------------------------------------------------------------- 1 | package com.container.auto.config; 2 | 3 | import com.container.auto.handler.AutoHandler; 4 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | @EnableConfigurationProperties(ProfileProperty.class) 10 | public class ServerConfig { 11 | 12 | @Bean 13 | AutoHandler autoHandler(ProfileProperty profileProperty) { 14 | return new AutoHandler(profileProperty); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /githubaction-deploy/src/main/java/com/container/auto/router/AutoRouter.java: -------------------------------------------------------------------------------- 1 | package com.container.auto.router; 2 | 3 | import com.container.auto.handler.AutoHandler; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.reactive.function.server.RouterFunction; 7 | import org.springframework.web.reactive.function.server.RouterFunctions; 8 | import org.springframework.web.reactive.function.server.ServerResponse; 9 | 10 | @Configuration 11 | public class AutoRouter { 12 | 13 | @Bean 14 | RouterFunction autoRouterFunction(AutoHandler autoHandler) { 15 | return RouterFunctions.route() 16 | .GET("/profile", autoHandler::getProfile) 17 | .build(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /githubaction-deploy/src/main/resources/application-local.yml: -------------------------------------------------------------------------------- 1 | server: 2 | profile: ${LOCAL_PROFILE} 3 | port: 8081 -------------------------------------------------------------------------------- /githubaction-deploy/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | server: 2 | profile: ${PROD_PROFILE} 3 | port: 8080 -------------------------------------------------------------------------------- /githubaction-deploy/src/test/java/com/container/auto/AutoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.container.auto; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class AutoApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /gradle-multi-module-master/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | /build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | 6 | ### STS ### 7 | .apt_generated 8 | .classpath 9 | .factorypath 10 | .project 11 | .settings 12 | .springBeans 13 | .sts4-cache 14 | 15 | ### IntelliJ IDEA ### 16 | .idea 17 | *.iws 18 | *.iml 19 | *.ipr 20 | /out/ 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | 29 | ### VS Code ### 30 | .vscode/ -------------------------------------------------------------------------------- /gradle-multi-module-master/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/gradle-multi-module-master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle-multi-module-master/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Apr 02 16:19:39 KST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip 7 | -------------------------------------------------------------------------------- /gradle-multi-module-master/sample-admin/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compile('org.springframework.boot:spring-boot-starter-web') 3 | testCompile('org.springframework.boot:spring-boot-starter-test') 4 | } -------------------------------------------------------------------------------- /gradle-multi-module-master/sample-admin/src/main/java/com/sungjun/admin/SampleAdminApplication.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.admin; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication(scanBasePackages = "com.sungjun") 7 | public class SampleAdminApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SampleAdminApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /gradle-multi-module-master/sample-admin/src/main/java/com/sungjun/admin/member/MemberController.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.admin.member; 2 | 3 | import com.sungjun.common.member.Member; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class MemberController { 9 | 10 | @GetMapping("/") 11 | public Member get() { 12 | return new Member("sungjun", "sungjun@gmail.com"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /gradle-multi-module-master/sample-admin/src/main/resources/application.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/gradle-multi-module-master/sample-admin/src/main/resources/application.yml -------------------------------------------------------------------------------- /gradle-multi-module-master/sample-admin/src/test/java/com/sungjun/admin/SampleAdminApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.admin; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | import static org.junit.Assert.assertEquals; 9 | 10 | @RunWith(SpringRunner.class) 11 | @SpringBootTest 12 | public class SampleAdminApplicationTest { 13 | 14 | @Test 15 | public void contextLoads() { 16 | assertEquals("1", "1"); 17 | } 18 | } -------------------------------------------------------------------------------- /gradle-multi-module-master/sample-api/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compile('org.springframework.boot:spring-boot-starter-web') 3 | testCompile('org.springframework.boot:spring-boot-starter-test') 4 | } -------------------------------------------------------------------------------- /gradle-multi-module-master/sample-api/src/main/java/com/sungjun/api/SampleApiApplication.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.api; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.domain.EntityScan; 6 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 7 | 8 | @SpringBootApplication 9 | @EntityScan("com.sungjun.*") 10 | @EnableJpaRepositories("com.sungjun.*") 11 | public class SampleApiApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(SampleApiApplication.class, args); 15 | } 16 | } -------------------------------------------------------------------------------- /gradle-multi-module-master/sample-api/src/main/java/com/sungjun/api/service/MemberServiceCustom.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.api.service; 2 | 3 | import com.sungjun.common.member.Member; 4 | import com.sungjun.common.repository.MemberRepository; 5 | import org.springframework.stereotype.Service; 6 | 7 | @Service 8 | public class MemberServiceCustom { 9 | 10 | private MemberRepository memberRepository; 11 | 12 | public MemberServiceCustom(MemberRepository memberRepository) { 13 | this.memberRepository = memberRepository; 14 | } 15 | 16 | public Long singup (Member member) { 17 | return memberRepository.save(member).getId(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gradle-multi-module-master/sample-api/src/main/resources/application.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/gradle-multi-module-master/sample-api/src/main/resources/application.yml -------------------------------------------------------------------------------- /gradle-multi-module-master/sample-common/build.gradle: -------------------------------------------------------------------------------- 1 | bootJar { 2 | enabled = false 3 | } 4 | jar { 5 | enabled = true 6 | } 7 | dependencies { 8 | compile('org.springframework.boot:spring-boot-starter-data-jpa') 9 | runtime('com.h2database:h2') 10 | testCompile('org.springframework.boot:spring-boot-starter-test') 11 | } -------------------------------------------------------------------------------- /gradle-multi-module-master/sample-common/src/main/java/com/sungjun/common/repository/MemberRepository.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.common.repository; 2 | 3 | import com.sungjun.common.member.Member; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface MemberRepository extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /gradle-multi-module-master/sample-common/src/test/java/com/sungjun/common/ModuleCommonApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.common; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | 5 | @SpringBootApplication 6 | public class ModuleCommonApplicationTests { 7 | public void contextLoads(){} 8 | } 9 | -------------------------------------------------------------------------------- /gradle-multi-module-master/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'sample-multi-module' 2 | include 'sample-api' 3 | include 'sample-admin' 4 | include 'sample-common' -------------------------------------------------------------------------------- /http/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /http/README.md: -------------------------------------------------------------------------------- 1 | Http request practice using intellij IDEA -------------------------------------------------------------------------------- /http/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.4.4' 3 | id 'io.spring.dependency-management' version '1.0.11.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'com.test' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '11' 10 | 11 | configurations { 12 | compileOnly { 13 | extendsFrom annotationProcessor 14 | } 15 | } 16 | 17 | repositories { 18 | mavenCentral() 19 | } 20 | 21 | dependencies { 22 | implementation 'org.springframework.boot:spring-boot-starter-webflux' 23 | compileOnly 'org.projectlombok:lombok' 24 | annotationProcessor 'org.projectlombok:lombok' 25 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 26 | testImplementation 'io.projectreactor:reactor-test' 27 | } 28 | 29 | test { 30 | useJUnitPlatform() 31 | } 32 | -------------------------------------------------------------------------------- /http/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/http/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /http/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /http/http/productGet.http: -------------------------------------------------------------------------------- 1 | GET localhost:8080/api/product -------------------------------------------------------------------------------- /http/http/productGetCookie.http: -------------------------------------------------------------------------------- 1 | GET localhost:8080/api/product 2 | Cookie: userId=123 -------------------------------------------------------------------------------- /http/http/productPost.http: -------------------------------------------------------------------------------- 1 | POST localhost:8080/api/product 2 | Content-Type: application/json 3 | 4 | { 5 | "id": 2, 6 | "name": "IPhone", 7 | "price": 1000000 8 | } -------------------------------------------------------------------------------- /http/http/productPostAuthorization.http: -------------------------------------------------------------------------------- 1 | POST localhost:8080/api/product 2 | Authorization: Bearer token-token-token -------------------------------------------------------------------------------- /http/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'http' 2 | -------------------------------------------------------------------------------- /http/src/main/java/com/test/http/HttpApplication.java: -------------------------------------------------------------------------------- 1 | package com.test.http; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class HttpApplication { 8 | 9 | // Webflux 10 | public static void main(String[] args) { 11 | SpringApplication.run(HttpApplication.class, args); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /http/src/main/java/com/test/http/controller/ProductController.java: -------------------------------------------------------------------------------- 1 | package com.test.http.controller; 2 | 3 | 4 | import com.test.http.controller.dto.ProductDTO; 5 | import org.springframework.web.bind.annotation.*; 6 | 7 | @RequestMapping("/api/product") 8 | @RestController 9 | public class ProductController { 10 | 11 | @GetMapping 12 | public ProductDTO getProduct() { 13 | return ProductDTO.getProductDTO(); 14 | } 15 | 16 | 17 | @PostMapping 18 | public ProductDTO addProduct(@RequestBody ProductDTO productDTO) { 19 | return productDTO; 20 | } 21 | 22 | @PutMapping 23 | public ProductDTO updateProduct(@RequestBody int price) { 24 | ProductDTO productDTO = ProductDTO.getProductDTO(); 25 | productDTO.setPrice(price); 26 | return productDTO; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /http/src/main/java/com/test/http/controller/dto/ProductDTO.java: -------------------------------------------------------------------------------- 1 | package com.test.http.controller.dto; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | @Setter 7 | @Getter 8 | public class ProductDTO { 9 | private Long id; 10 | private String name; 11 | private int price; 12 | 13 | public ProductDTO(Long id, String name, int price) { 14 | this.id = id; 15 | this.name = name; 16 | this.price = price; 17 | } 18 | 19 | public static ProductDTO getProductDTO() { 20 | return new ProductDTO(1L, "GALAXY S21", 999_999); 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /http/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /http/src/test/java/com/test/http/HttpApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.test.http; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class HttpApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /importOrComponentScan/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /importOrComponentScan/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.4.5' 3 | id 'io.spring.dependency-management' version '1.0.11.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'com.test' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '11' 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | dependencies { 16 | implementation 'org.springframework.boot:spring-boot-starter-web' 17 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 18 | } 19 | 20 | test { 21 | useJUnitPlatform() 22 | } 23 | -------------------------------------------------------------------------------- /importOrComponentScan/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/importOrComponentScan/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /importOrComponentScan/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /importOrComponentScan/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'importOrComponentScan' 2 | -------------------------------------------------------------------------------- /importOrComponentScan/src/main/java/com/test/componentscanconfig/README.md: -------------------------------------------------------------------------------- 1 | # Getting configurations using ComponentScan annotation 2 | 3 | `@ComponentScan`을 통해 Configuration 클래스들을 등록할 수 있다. 4 | - `@SpringBootApplication`은 `@ComponentScan`을 포함하는 어노테이션이기에 기본적인 구조(spring initializer를 사용한 상황)에선 Component scan을 사용한 방식으로 Configuration을 등록하게 된다. -------------------------------------------------------------------------------- /importOrComponentScan/src/main/java/com/test/componentscanconfig/config/AnotherConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.test.componentscanconfig.config; 2 | 3 | import com.test.componentscanconfig.service.AnotherService; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | @Configuration 8 | public class AnotherConfiguration { 9 | 10 | @Bean 11 | public AnotherService anotherService() { 12 | return new AnotherService(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /importOrComponentScan/src/main/java/com/test/componentscanconfig/config/CommonConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.test.componentscanconfig.config; 2 | 3 | import com.test.componentscanconfig.service.CommonService; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | @Configuration 8 | public class CommonConfiguration { 9 | 10 | @Bean 11 | public CommonService commonService() { 12 | return new CommonService(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /importOrComponentScan/src/main/java/com/test/componentscanconfig/service/AnotherService.java: -------------------------------------------------------------------------------- 1 | package com.test.componentscanconfig.service; 2 | 3 | public class AnotherService { 4 | } 5 | -------------------------------------------------------------------------------- /importOrComponentScan/src/main/java/com/test/componentscanconfig/service/CommonService.java: -------------------------------------------------------------------------------- 1 | package com.test.componentscanconfig.service; 2 | 3 | public class CommonService { 4 | } 5 | -------------------------------------------------------------------------------- /importOrComponentScan/src/main/java/com/test/importconfig/README.md: -------------------------------------------------------------------------------- 1 | # Getting configurations using Import annotation 2 | 3 | `@Import`를 통해 Configuration 클래스들을 등록할 수 있다. -------------------------------------------------------------------------------- /importOrComponentScan/src/main/java/com/test/importconfig/config/AnotherConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.test.importconfig.config; 2 | 3 | import com.test.importconfig.service.AnotherService; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | @Configuration 8 | public class AnotherConfiguration { 9 | 10 | @Bean 11 | public AnotherService anotherService() { 12 | return new AnotherService(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /importOrComponentScan/src/main/java/com/test/importconfig/config/CommonConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.test.importconfig.config; 2 | 3 | import com.test.importconfig.service.CommonService; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | @Configuration 8 | public class CommonConfiguration { 9 | 10 | @Bean 11 | public CommonService commonService() { 12 | return new CommonService(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /importOrComponentScan/src/main/java/com/test/importconfig/config/OneMoreConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.test.importconfig.config; 2 | 3 | import com.test.importconfig.service.OneMoreService; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | @Configuration 8 | public class OneMoreConfiguration { 9 | 10 | @Bean 11 | public OneMoreService oneMoreService() { 12 | return new OneMoreService(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /importOrComponentScan/src/main/java/com/test/importconfig/service/AllNewService.java: -------------------------------------------------------------------------------- 1 | package com.test.importconfig.service; 2 | 3 | public class AllNewService { 4 | private final CommonService commonService; 5 | private final AnotherService anotherService; 6 | private final OneMoreService oneMoreService; 7 | 8 | public AllNewService(CommonService commonService, AnotherService anotherService, OneMoreService oneMoreService) { 9 | this.commonService = commonService; 10 | this.anotherService = anotherService; 11 | this.oneMoreService = oneMoreService; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /importOrComponentScan/src/main/java/com/test/importconfig/service/AnotherService.java: -------------------------------------------------------------------------------- 1 | package com.test.importconfig.service; 2 | 3 | public class AnotherService { 4 | } 5 | -------------------------------------------------------------------------------- /importOrComponentScan/src/main/java/com/test/importconfig/service/CommonService.java: -------------------------------------------------------------------------------- 1 | package com.test.importconfig.service; 2 | 3 | public class CommonService { 4 | } 5 | -------------------------------------------------------------------------------- /importOrComponentScan/src/main/java/com/test/importconfig/service/OneMoreService.java: -------------------------------------------------------------------------------- 1 | package com.test.importconfig.service; 2 | 3 | public class OneMoreService { 4 | } 5 | -------------------------------------------------------------------------------- /importOrComponentScan/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | debug=true -------------------------------------------------------------------------------- /importOrComponentScan/src/test/java/com/test/importorcomponentscan/ComponentScanConfigApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.test.importorcomponentscan; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ComponentScanConfigApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /jpa/jpa practices/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /jpa/jpa practices/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/jpa/jpa practices/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /jpa/jpa practices/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /jpa/jpa practices/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'jpa' 2 | -------------------------------------------------------------------------------- /jpa/jpa practices/src/main/java/com/practice/jpa/JpaApplication.java: -------------------------------------------------------------------------------- 1 | package com.practice.jpa; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.data.jpa.repository.config.EnableJpaAuditing; 6 | 7 | @EnableJpaAuditing 8 | @SpringBootApplication 9 | public class JpaApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(JpaApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /jpa/jpa practices/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | h2: # h2 활성화 3 | console: 4 | enabled: true 5 | path: /h2-console 6 | datasource: # db 설정 7 | hikari: 8 | driver-class-name: org.h2.Driver 9 | jdbc-url: jdbc:h2:tcp://localhost:9092/mem:testdb 10 | username: sa 11 | password: 12 | jpa: # jpa 설정 13 | database-platform: org.hibernate.dialect.H2Dialect 14 | show-sql: true 15 | hibernate: 16 | ddl-auto: create-drop 17 | properties: 18 | hibernate: 19 | format_sql: true 20 | open-in-view: false 21 | defer-datasource-initialization: true # hibernate 초기화 후 데이터 추가 22 | config: 23 | activate: 24 | on-profile: local 25 | sql: # 초기 데이터 26 | init: 27 | data-locations: classpath:data/data.sql 28 | mode: always -------------------------------------------------------------------------------- /jpa/jpa practices/src/test/java/com/practice/jpa/JpaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.practice.jpa; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class JpaApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /jpa/spring-boot-jpa/jpashop/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /jpa/spring-boot-jpa/jpashop/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/jpa/spring-boot-jpa/jpashop/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /jpa/spring-boot-jpa/jpashop/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /jpa/spring-boot-jpa/jpashop/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'jpashop' 2 | -------------------------------------------------------------------------------- /jpa/spring-boot-jpa/jpashop/src/main/java/jpabook/jpashop/HelloController.java: -------------------------------------------------------------------------------- 1 | package jpabook.jpashop; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | 7 | @Controller 8 | public class HelloController { 9 | 10 | @GetMapping("hello") 11 | public String hello(Model model) { 12 | model.addAttribute("data", "Hello !"); 13 | return "hello"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /jpa/spring-boot-jpa/jpashop/src/main/java/jpabook/jpashop/JpashopApplication.java: -------------------------------------------------------------------------------- 1 | package jpabook.jpashop; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class JpashopApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(JpashopApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /jpa/spring-boot-jpa/jpashop/src/main/java/jpabook/jpashop/Member.java: -------------------------------------------------------------------------------- 1 | package jpabook.jpashop; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.Id; 9 | 10 | @Entity 11 | @Getter 12 | @Setter 13 | public class Member { 14 | @Id 15 | @GeneratedValue 16 | private Long id; 17 | private String username; 18 | } 19 | -------------------------------------------------------------------------------- /jpa/spring-boot-jpa/jpashop/src/main/java/jpabook/jpashop/MemberRepository.java: -------------------------------------------------------------------------------- 1 | package jpabook.jpashop; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.PersistenceContext; 7 | 8 | @Repository 9 | public class MemberRepository { 10 | @PersistenceContext 11 | EntityManager em; 12 | 13 | public Long save(Member member){ 14 | em.persist(member); 15 | return member.getId(); 16 | } 17 | 18 | public Member find(Long id){ 19 | return em.find(Member.class, id); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jpa/spring-boot-jpa/jpashop/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | url: jdbc:h2:tcp://localhost/~/jpashop 4 | username: sa 5 | password: 6 | driver-class-name: org.h2.Driver 7 | 8 | jpa: 9 | hibernate: 10 | ddl-auto: create 11 | properties: 12 | hibernate: 13 | format_sql: true 14 | logging: 15 | level: 16 | org:hibernate.SQL: debug -------------------------------------------------------------------------------- /jpa/spring-boot-jpa/jpashop/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello 5 | 6 | 7 | 8 | Hello 9 | hello 10 | 11 | -------------------------------------------------------------------------------- /jpa/spring-boot-jpa/jpashop/src/main/resources/templates/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello 5 | 6 | 7 | 8 |

안녕하세요. 손님

9 | 10 | -------------------------------------------------------------------------------- /junit5/tag/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /junit5/tag/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/junit5/tag/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /junit5/tag/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /junit5/tag/images/Untitled 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/junit5/tag/images/Untitled 1.png -------------------------------------------------------------------------------- /junit5/tag/images/Untitled 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/junit5/tag/images/Untitled 2.png -------------------------------------------------------------------------------- /junit5/tag/images/Untitled 3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/junit5/tag/images/Untitled 3.png -------------------------------------------------------------------------------- /junit5/tag/images/Untitled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/junit5/tag/images/Untitled.png -------------------------------------------------------------------------------- /junit5/tag/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'tag' 2 | -------------------------------------------------------------------------------- /junit5/tag/src/test/java/com/junit5/tag/ApplicationIntegrationTests.java: -------------------------------------------------------------------------------- 1 | package com.junit5.tag; 2 | 3 | import org.junit.jupiter.api.Tag; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.assertj.core.api.Assertions.assertThat; 7 | 8 | @Tag("integration") 9 | class ApplicationIntegrationTests { 10 | 11 | @Test 12 | void integrationTest() { 13 | // SpringBoot start 14 | assertThat("Start").isEqualTo("Start"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /keycloak/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /keycloak/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/keycloak/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /keycloak/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /keycloak/http/request.http: -------------------------------------------------------------------------------- 1 | GET http://localhost:8081/api/v1/permit 2 | 3 | ### 4 | 5 | GET http://localhost:8081/api/v1/remainder/restrict -------------------------------------------------------------------------------- /keycloak/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'keycloak' 2 | -------------------------------------------------------------------------------- /keycloak/src/main/java/com/security/keycloak/KeycloakApplication.java: -------------------------------------------------------------------------------- 1 | package com.security.keycloak; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class KeycloakApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(KeycloakApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /keycloak/src/main/java/com/security/keycloak/KeycloakTestController.java: -------------------------------------------------------------------------------- 1 | package com.security.keycloak; 2 | 3 | import org.springframework.http.ResponseEntity; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | @RequestMapping("/api/v1") 10 | public class KeycloakTestController { 11 | 12 | @GetMapping("/permit") 13 | public ResponseEntity permitEndpoint() { 14 | return ResponseEntity.ok("THIS ENDPOINT IS PERMITTED"); 15 | } 16 | 17 | @GetMapping("/remainder/restrict") 18 | public ResponseEntity restrictEndpoint() { 19 | return ResponseEntity.ok("THIS ENDPOINT IS RESTRICTED"); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /keycloak/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8081 -------------------------------------------------------------------------------- /keycloak/src/main/resources/keycloak.json: -------------------------------------------------------------------------------- 1 | { 2 | "realm": "bb", 3 | "auth-server-url": "http://localhost:8080/auth", 4 | "ssl-required": "external", 5 | "resource": "bb1", 6 | "credentials": { 7 | "secret": "293c9c1a-8416-4305-97d9-2c8be9216152" 8 | }, 9 | "confidential-port": 0 10 | } -------------------------------------------------------------------------------- /keycloak/src/test/java/com/security/keycloak/KeycloakApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.security.keycloak; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class KeycloakApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /log/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /log/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.4.5' 3 | id 'io.spring.dependency-management' version '1.0.11.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'com.test' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '11' 10 | 11 | configurations { 12 | compileOnly { 13 | extendsFrom annotationProcessor 14 | } 15 | } 16 | 17 | repositories { 18 | mavenCentral() 19 | } 20 | 21 | dependencies { 22 | implementation 'org.springframework.boot:spring-boot-starter-web' 23 | compileOnly 'org.projectlombok:lombok' 24 | annotationProcessor 'org.projectlombok:lombok' 25 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 26 | } 27 | 28 | test { 29 | useJUnitPlatform() 30 | } 31 | -------------------------------------------------------------------------------- /log/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/log/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /log/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /log/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'log' 2 | -------------------------------------------------------------------------------- /log/src/main/java/com/test/log/LogApplication.java: -------------------------------------------------------------------------------- 1 | package com.test.log; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableScheduling; 6 | 7 | @EnableScheduling 8 | @SpringBootApplication 9 | public class LogApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(LogApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /log/src/main/java/com/test/log/LogScheduler.java: -------------------------------------------------------------------------------- 1 | package com.test.log; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.scheduling.annotation.Scheduled; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class LogScheduler { 10 | private static final Logger log = LoggerFactory.getLogger(LogScheduler.class); 11 | 12 | @Scheduled(fixedRate = 2000) 13 | public void makeDebugLog() { 14 | log.debug("This is\na debug\nlog"); 15 | } 16 | 17 | @Scheduled(fixedRate = 5000) 18 | public void makeInfoLog() { 19 | log.info("This is\na info\nlog"); 20 | } 21 | 22 | @Scheduled(fixedRate = 8000) 23 | public void logException() { 24 | throw new RuntimeException("! Error happened !"); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /log/src/main/java/com/test/log/user/LogUserScheduler.java: -------------------------------------------------------------------------------- 1 | package com.test.log.user; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.scheduling.annotation.Scheduled; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class LogUserScheduler { 10 | private static final Logger log = LoggerFactory.getLogger(LogUserScheduler.class); 11 | 12 | @Scheduled(fixedRate = 5000) 13 | public void makeDebugLog() { 14 | log.debug("This is\na \"USER\" debug\nlog"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /log/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | debug=true 2 | 3 | ########## set log print level 4 | #logging.level.com.test.log=DEBUG 5 | 6 | ########## write log files 7 | # if name is null, name set 'spring.log' 8 | # properties 파일에서 logging.file.name과 logging.file.path를 함께 사용하면 logging.file.name만 적용된다. 9 | # 만약 함께 지정하고 싶다면, name 속성에 directory를 명시할 것. 10 | #logging.file.path=./logs/directory/here 11 | logging.file.name=./logs/directory/here/test_log_file.log 12 | 13 | ######## log rolling policy 14 | #logging.logback.rollingpolicy.max-file-size=1KB 15 | 16 | ###### log group 17 | logging.group.myuser=com.test.log.user 18 | logging.level.myuser=DEBUG 19 | logging.level.web=DEBUG -------------------------------------------------------------------------------- /log/src/test/java/com/test/log/LogApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.test.log; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class LogApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /opentelemetry/issue-demo/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/opentelemetry/issue-demo/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /opentelemetry/issue-demo/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /opentelemetry/issue-demo/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "demo" 2 | -------------------------------------------------------------------------------- /opentelemetry/issue-demo/src/main/java/com/example/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 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 | -------------------------------------------------------------------------------- /opentelemetry/issue-demo/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=demo 2 | -------------------------------------------------------------------------------- /opentelemetry/issue-demo/src/test/java/com/example/demo/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 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 | -------------------------------------------------------------------------------- /prometheus/.gitattributes: -------------------------------------------------------------------------------- 1 | /gradlew text eol=lf 2 | *.bat text eol=crlf 3 | *.jar binary 4 | -------------------------------------------------------------------------------- /prometheus/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | 39 | ### Kotlin ### 40 | .kotlin 41 | -------------------------------------------------------------------------------- /prometheus/README.md: -------------------------------------------------------------------------------- 1 | # TEST Prometheus Project 2 | 3 | --- 4 | 5 | http://localhost:8081/monitoring 6 | 7 | --- 8 | 9 | 10 | http://localhost:8081/monitoring/metrics/domain.foo.count 11 | 12 | - http://localhost:8081/monitoring/metrics/domain.foo.count?tag=how:counter 13 | - http://localhost:8081/monitoring/metrics/domain.foo.count?tag=how:meterBinder 14 | - http://localhost:8081/monitoring/metrics/domain.foo.count?tag=how:annotation 15 | 16 | --- 17 | 18 | http://localhost:8081/monitoring/prometheus 19 | 20 | -------------------------------------------------------------------------------- /prometheus/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/prometheus/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /prometheus/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /prometheus/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "prometheus" 2 | -------------------------------------------------------------------------------- /prometheus/src/main/kotlin/com/micrometer/prometheus/PrometheusApplication.kt: -------------------------------------------------------------------------------- 1 | package com.micrometer.prometheus 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication 4 | import org.springframework.boot.runApplication 5 | 6 | @SpringBootApplication 7 | class PrometheusApplication 8 | 9 | fun main(args: Array) { 10 | runApplication(*args) 11 | } 12 | -------------------------------------------------------------------------------- /prometheus/src/main/kotlin/com/micrometer/prometheus/domain/FooCount.kt: -------------------------------------------------------------------------------- 1 | package com.micrometer.prometheus.domain 2 | 3 | import io.micrometer.core.instrument.Counter 4 | import io.micrometer.core.instrument.MeterRegistry 5 | import org.springframework.stereotype.Component 6 | 7 | @Component 8 | class FooCount(meterRegistry: MeterRegistry) { 9 | 10 | private val counter = Counter.builder("domain.foo.count") 11 | .description("foo domain count") 12 | .tag("how", "counter") 13 | .register(meterRegistry) 14 | 15 | fun increase() { 16 | counter.increment() 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /prometheus/src/main/kotlin/com/micrometer/prometheus/domain/FooData.kt: -------------------------------------------------------------------------------- 1 | package com.micrometer.prometheus.domain 2 | 3 | import org.springframework.stereotype.Component 4 | import java.util.concurrent.atomic.AtomicLong 5 | 6 | @Component 7 | class FooData { 8 | 9 | val count = AtomicLong(0) 10 | 11 | 12 | fun get(): Long { 13 | return count.get() 14 | } 15 | 16 | fun increaseAndGet() { 17 | count.incrementAndGet() 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /prometheus/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: "prometheus-demo" 4 | 5 | management: 6 | server: 7 | port: 8081 8 | endpoints: 9 | enabled-by-default: false 10 | web: 11 | base-path: /monitoring 12 | exposure: 13 | include: health, metrics, prometheus 14 | endpoint: 15 | health: 16 | enabled: true 17 | metrics: 18 | enabled: true 19 | prometheus: 20 | enabled: true 21 | -------------------------------------------------------------------------------- /prometheus/src/test/kotlin/com/micrometer/prometheus/PrometheusApplicationTests.kt: -------------------------------------------------------------------------------- 1 | package com.micrometer.prometheus 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.springframework.boot.test.context.SpringBootTest 5 | 6 | @SpringBootTest 7 | class PrometheusApplicationTests { 8 | 9 | @Test 10 | fun contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /prometheus/test.http: -------------------------------------------------------------------------------- 1 | GET http://127.0.0.1:8080/metrics/count/counter 2 | 3 | ### 4 | GET http://127.0.0.1:8080/metrics/count/meterBinder 5 | 6 | ### 7 | GET http://127.0.0.1:8080/metrics/count/annotation 8 | 9 | -------------------------------------------------------------------------------- /property-validation/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /property-validation/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/property-validation/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /property-validation/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /property-validation/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'property-validation' 2 | -------------------------------------------------------------------------------- /property-validation/src/main/java/com/example/propertyvalidation/PropertyValidationApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.propertyvalidation; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.springframework.boot.CommandLineRunner; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | 8 | @SpringBootApplication 9 | @RequiredArgsConstructor 10 | public class PropertyValidationApplication implements CommandLineRunner { 11 | 12 | private final ServerProperties serverProperties; 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(PropertyValidationApplication.class, args); 16 | } 17 | 18 | @Override 19 | public void run(String... args) throws Exception { 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /property-validation/src/main/java/com/example/propertyvalidation/ServerConfig.java: -------------------------------------------------------------------------------- 1 | package com.example.propertyvalidation; 2 | 3 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | @EnableConfigurationProperties(ServerProperties.class) 8 | public class ServerConfig { 9 | } 10 | -------------------------------------------------------------------------------- /property-validation/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | value-1: 30 3 | value-2: 10 4 | -------------------------------------------------------------------------------- /property-validation/src/test/java/com/example/propertyvalidation/PropertyValidationApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.propertyvalidation; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class PropertyValidationApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /queue-sqs/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.{adoc, bat, groovy, html, java, js, jsp, kt, kts, md, properties, py, rb, sh, sql, svg, txt, xml, xsd}] 4 | charset = utf-8 5 | 6 | [*.{groovy, java, kt, kts, xml, xsd}] 7 | indent_style = space 8 | indent_size = 4 9 | continuation_indent_size = 4 10 | end_of_line = lf -------------------------------------------------------------------------------- /queue-sqs/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /queue-sqs/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/queue-sqs/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /queue-sqs/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /queue-sqs/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'push' 2 | -------------------------------------------------------------------------------- /queue-sqs/src/main/java/com/queue/push/PushApplication.java: -------------------------------------------------------------------------------- 1 | package com.queue.push; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class PushApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(PushApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /queue-sqs/src/main/java/com/queue/push/infra/config/AwsCredentialProperty.java: -------------------------------------------------------------------------------- 1 | package com.queue.push.infra.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.boot.context.properties.ConstructorBinding; 5 | 6 | @ConstructorBinding 7 | @ConfigurationProperties(prefix = "cloud.aws.credentials") 8 | public record AwsCredentialProperty(String accessKey, String secretKey) { 9 | } 10 | -------------------------------------------------------------------------------- /queue-sqs/src/main/java/com/queue/push/infra/config/AwsSqsProperty.java: -------------------------------------------------------------------------------- 1 | package com.queue.push.infra.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.boot.context.properties.ConstructorBinding; 5 | 6 | @ConstructorBinding 7 | @ConfigurationProperties(prefix = "cloud.aws.sqs.queue") 8 | public record AwsSqsProperty(String someQueueUrl) { 9 | } 10 | -------------------------------------------------------------------------------- /queue-sqs/src/main/java/com/queue/push/queue/MessageReceiver.java: -------------------------------------------------------------------------------- 1 | package com.queue.push.queue; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.cloud.aws.messaging.listener.annotation.SqsListener; 5 | import org.springframework.messaging.handler.annotation.Headers; 6 | import org.springframework.messaging.handler.annotation.Payload; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.Map; 10 | 11 | @Component 12 | @Slf4j 13 | public class MessageReceiver { 14 | 15 | @SqsListener(value = "${cloud.aws.sqs.queue.some-queue-name}") 16 | public void receiveSomeQueue(@Headers Map header, 17 | @Payload String message) { 18 | log.info("header {}", header); 19 | log.info("message {}", message); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /queue-sqs/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | cloud: 2 | aws: 3 | credentials: 4 | access-key: ${AWS_ACCESS_KEY} 5 | secret-key: ${AWS_SECRET_KEY} 6 | region: 7 | static: "ap-northeast-2" 8 | stack: 9 | auto: false 10 | sqs: 11 | queue: 12 | some-queue-name: ${AWS_SQS_NAME} 13 | some-queue-url: ${AWS_SQS_URL} 14 | other-queue-name: ${AWS_SQS_NAME} 15 | other-queue-url: ${AWS_SQS_URL} 16 | -------------------------------------------------------------------------------- /queue-sqs/src/test/java/com/queue/push/PushApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.queue.push; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class PushApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /reactor-exapnd/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /reactor-exapnd/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/reactor-exapnd/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /reactor-exapnd/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /reactor-exapnd/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'reactor-exapnd' 2 | -------------------------------------------------------------------------------- /reactor-exapnd/src/main/java/com/example/reactorexapnd/domain/Post.java: -------------------------------------------------------------------------------- 1 | package com.example.reactorexapnd.domain; 2 | 3 | public record Post(Long postId, Long userId, String content) {} 4 | -------------------------------------------------------------------------------- /reactor-exapnd/src/main/java/com/example/reactorexapnd/domain/PostList.java: -------------------------------------------------------------------------------- 1 | package com.example.reactorexapnd.domain; 2 | 3 | import java.util.List; 4 | 5 | public record PostList(Long postPageId, List posts, Long nextPageId) {} 6 | -------------------------------------------------------------------------------- /reactor-exapnd/src/main/java/com/example/reactorexapnd/domain/PostListRepository.java: -------------------------------------------------------------------------------- 1 | package com.example.reactorexapnd.domain; 2 | 3 | import reactor.core.publisher.Mono; 4 | 5 | public interface PostListRepository { 6 | 7 | void addPostList(PostList postList); 8 | 9 | Mono findAllPostsByUserId(long userId, Long pageId); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /reactor-exapnd/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /reactor-exapnd/src/test/java/com/example/reactorexapnd/ReactorExapndTestTests.java: -------------------------------------------------------------------------------- 1 | package com.example.reactorexapnd; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ReactorExapndTestTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /reactor-webflux-testbed/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /reactor-webflux-testbed/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.6.1' 3 | id 'io.spring.dependency-management' version '1.0.11.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'com.reactor' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '17' 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | dependencies { 16 | implementation 'org.springframework.boot:spring-boot-starter-webflux' 17 | compileOnly 'org.projectlombok:lombok' 18 | annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' 19 | annotationProcessor 'org.projectlombok:lombok' 20 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 21 | testImplementation 'io.projectreactor:reactor-test' 22 | } 23 | 24 | test { 25 | useJUnitPlatform() 26 | } 27 | -------------------------------------------------------------------------------- /reactor-webflux-testbed/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/reactor-webflux-testbed/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /reactor-webflux-testbed/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /reactor-webflux-testbed/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'test' 2 | -------------------------------------------------------------------------------- /reactor-webflux-testbed/src/main/java/com/reactor/test/TestApplication.java: -------------------------------------------------------------------------------- 1 | package com.reactor.test; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class TestApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(TestApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /reactor-webflux-testbed/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /redis/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /redis/data/.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/redis/data/.txt -------------------------------------------------------------------------------- /redis/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.9' 2 | 3 | services: 4 | redis: 5 | image: redis:6.2 6 | command: redis-server --requirepass 1234 --port 6379 7 | restart: always 8 | user: "501:20" # set UID/GID using id 9 | ports: 10 | - 6379:6379 11 | volumes: 12 | - ./data:/data:rw -------------------------------------------------------------------------------- /redis/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/redis/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /redis/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /redis/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'redis' 2 | -------------------------------------------------------------------------------- /redis/src/main/java/com/redis/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.redis.demo; 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 | -------------------------------------------------------------------------------- /redis/src/main/java/com/redis/demo/Member.java: -------------------------------------------------------------------------------- 1 | package com.redis.demo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import org.springframework.data.annotation.Id; 5 | import org.springframework.data.redis.core.RedisHash; 6 | import org.springframework.data.redis.core.TimeToLive; 7 | 8 | @AllArgsConstructor 9 | @RedisHash(value = "member") 10 | public class Member { 11 | 12 | @Id 13 | private final Long id; 14 | 15 | @TimeToLive 16 | private final Long ttl; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /redis/src/main/java/com/redis/demo/MemberRepository.java: -------------------------------------------------------------------------------- 1 | package com.redis.demo; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | 5 | public interface MemberRepository extends CrudRepository { 6 | } 7 | -------------------------------------------------------------------------------- /redis/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | redis: 3 | host: localhost 4 | port: 6379 5 | password: 1234 6 | 7 | logging: 8 | level: 9 | root: INFO 10 | redis.clients: TRACE 11 | org.springframework.data: TRACE 12 | -------------------------------------------------------------------------------- /redis/src/test/java/com/redis/demo/RedisTest.java: -------------------------------------------------------------------------------- 1 | package com.redis.demo; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | 7 | import java.util.ArrayList; 8 | import java.util.stream.LongStream; 9 | 10 | @SpringBootTest 11 | class RedisTest { 12 | 13 | @Autowired 14 | MemberRepository memberRepository; 15 | 16 | @Test 17 | void 멤버를_저장할_수_있다() { 18 | var members = new ArrayList(); 19 | LongStream.range(0L, 10L).forEach(ind -> { 20 | members.add(new Member(ind, 50L)); 21 | }); 22 | memberRepository.saveAll(members); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /schedule/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /schedule/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.4.4' 3 | id 'io.spring.dependency-management' version '1.0.11.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'com.test' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '11' 10 | 11 | configurations { 12 | compileOnly { 13 | extendsFrom annotationProcessor 14 | } 15 | } 16 | 17 | repositories { 18 | mavenCentral() 19 | } 20 | 21 | dependencies { 22 | implementation 'org.springframework.boot:spring-boot-starter-web' 23 | compileOnly 'org.projectlombok:lombok' 24 | annotationProcessor 'org.projectlombok:lombok' 25 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 26 | } 27 | 28 | test { 29 | useJUnitPlatform() 30 | } 31 | -------------------------------------------------------------------------------- /schedule/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/schedule/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /schedule/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /schedule/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'schedule' 2 | -------------------------------------------------------------------------------- /schedule/src/main/java/com/test/schedule/ScheduleApplication.java: -------------------------------------------------------------------------------- 1 | package com.test.schedule; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ScheduleApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ScheduleApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /schedule/src/main/java/com/test/schedule/config/ScheduleConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.test.schedule.config; 2 | 3 | import com.test.schedule.scheduler.SecondScheduler; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.scheduling.annotation.EnableScheduling; 7 | 8 | import java.time.Clock; 9 | import java.time.ZoneId; 10 | 11 | @Configuration 12 | @EnableScheduling 13 | public class ScheduleConfiguration { 14 | 15 | @Bean 16 | public Clock clock() { 17 | return Clock.system(ZoneId.of("Asia/Seoul")); 18 | } 19 | 20 | @Bean 21 | public SecondScheduler secondScheduler(Clock clock) { 22 | return new SecondScheduler(clock); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /schedule/src/main/java/com/test/schedule/scheduler/SecondScheduler.java: -------------------------------------------------------------------------------- 1 | package com.test.schedule.scheduler; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.scheduling.annotation.Scheduled; 5 | 6 | import java.time.Clock; 7 | import java.time.LocalDateTime; 8 | 9 | @Slf4j 10 | public class SecondScheduler { 11 | 12 | private final Clock clock; 13 | 14 | public SecondScheduler(Clock clock) { 15 | this.clock = clock; 16 | } 17 | 18 | @Scheduled(cron = "* 30 * * * MON-FRI", zone = "Asia/Seoul") 19 | public void secondScheduleJob() { 20 | log.info("-- USE @Bean at Configuration --"); 21 | log.info("This is scheduled - Run every 30 minutes on weekdays ({})", LocalDateTime.now(clock)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /schedule/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | schedule: 2 | cron: "*/30 * * * * *" -------------------------------------------------------------------------------- /schedule/src/test/java/com/test/schedule/ScheduleApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.test.schedule; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ScheduleApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /security/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /security/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.6.4' 3 | id 'io.spring.dependency-management' version '1.0.11.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'com.spring' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '11' 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | dependencies { 16 | implementation 'org.springframework.boot:spring-boot-starter-security' 17 | implementation 'org.springframework.boot:spring-boot-starter-web' 18 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 19 | testImplementation 'org.springframework.security:spring-security-test' 20 | } 21 | 22 | tasks.named('test') { 23 | useJUnitPlatform() 24 | } 25 | -------------------------------------------------------------------------------- /security/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/security/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /security/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /security/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'security' 2 | -------------------------------------------------------------------------------- /security/src/main/java/com/spring/security/SecurityApplication.java: -------------------------------------------------------------------------------- 1 | package com.spring.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SecurityApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SecurityApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /security/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /security/src/test/java/com/spring/security/SecurityApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.spring.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SecurityApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /serverless/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /serverless/README.md: -------------------------------------------------------------------------------- 1 | `Spring Serverless.pdf` 파일 참고 2 | -------------------------------------------------------------------------------- /serverless/Spring Serverless.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/serverless/Spring Serverless.pdf -------------------------------------------------------------------------------- /serverless/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/serverless/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /serverless/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /serverless/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'serverless' 2 | -------------------------------------------------------------------------------- /serverless/src/main/java/com/kimdoubleb/serverless/ServerlessApplication.java: -------------------------------------------------------------------------------- 1 | package com.kimdoubleb.serverless; 2 | 3 | import java.util.Locale; 4 | import java.util.function.Function; 5 | 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.context.annotation.Bean; 9 | 10 | import lombok.extern.slf4j.Slf4j; 11 | 12 | @Slf4j 13 | @SpringBootApplication 14 | public class ServerlessApplication { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(ServerlessApplication.class, args); 18 | } 19 | 20 | @Bean 21 | public Function lowercase() { 22 | return request -> { 23 | log.info("** Request: {}", request); 24 | return request.toLowerCase(Locale.ROOT); 25 | }; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /serverless/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | 2 | spring: 3 | cloud: 4 | function: 5 | definition: lowercase 6 | -------------------------------------------------------------------------------- /serverless/src/test/java/com/kimdoubleb/serverless/ServerlessApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kimdoubleb.serverless; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ServerlessApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /servlet/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /servlet/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/servlet/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /servlet/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /servlet/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'servlet' 2 | -------------------------------------------------------------------------------- /servlet/src/main/java/hello/servlet/ServletApplication.java: -------------------------------------------------------------------------------- 1 | package hello.servlet; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.web.servlet.ServletComponentScan; 6 | 7 | @ServletComponentScan //서블릿 자동 등록 8 | @SpringBootApplication 9 | public class ServletApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ServletApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /servlet/src/main/java/hello/servlet/ServletInitializer.java: -------------------------------------------------------------------------------- 1 | package hello.servlet; 2 | 3 | import org.springframework.boot.builder.SpringApplicationBuilder; 4 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 5 | 6 | public class ServletInitializer extends SpringBootServletInitializer { 7 | 8 | @Override 9 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 10 | return application.sources(ServletApplication.class); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /servlet/src/main/java/hello/servlet/basic/HelloData.java: -------------------------------------------------------------------------------- 1 | package hello.servlet.basic; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | @Getter @Setter 7 | public class HelloData { 8 | 9 | private String username; 10 | private int age; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /servlet/src/main/java/hello/servlet/domain/member/Member.java: -------------------------------------------------------------------------------- 1 | package hello.servlet.domain.member; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | @Getter @Setter 7 | public class Member { 8 | 9 | private Long id; 10 | private String username; 11 | private int age; 12 | 13 | public Member() {} 14 | 15 | public Member(String username, int age) { 16 | this.username = username; 17 | this.age = age; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /servlet/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.org.apache.coyote.http11=debug 2 | -------------------------------------------------------------------------------- /servlet/src/test/java/hello/servlet/ServletApplicationTests.java: -------------------------------------------------------------------------------- 1 | package hello.servlet; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ServletApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-cloud-example/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | /out/ 20 | **/out/ 21 | ### NetBeans ### 22 | /nbproject/private/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ -------------------------------------------------------------------------------- /spring-cloud-example/README.md: -------------------------------------------------------------------------------- 1 | # Spring Cloud Example 2 | 스프링 클라우드 예제 3 | 4 | ## 다루고 있는 것들 5 | - Spring Cloud + Netflix 6 | - RestTemplate 7 | - hystrix 8 | - ribbon 9 | - eureka 10 | - feign 11 | - zuul 12 | 13 | ## Reference 14 | [Spring cloud workshop](https://github.com/yongsungyoon/spring-cloud-workshop) 15 | 16 | [Spring cloud workshop slideshare](https://www.slideshare.net/balladofgale/spring-cloud-workshop) 17 | 18 | [Spring cloud MSA 전환 - 11번가](https://www.slideshare.net/balladofgale/spring-camp-2018-11-spring-cloud-msa-1) 19 | 20 | [[Naver D2 발표] Spring cloud MSA 전환 - 11번가](https://www.youtube.com/watch?v=J-VP0WFEQsY) 21 | 22 | [다음 단계 - MSA Development Project with Spring Boot using Netflix OSS & Istio.io](https://github.com/mincloud1501/spring-cloud-workshop) 23 | -------------------------------------------------------------------------------- /spring-cloud-example/display/src/main/java/com/elevenst/service/FeignProductRemoteService.java: -------------------------------------------------------------------------------- 1 | package com.elevenst.service; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.web.bind.annotation.PathVariable; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | @FeignClient(name = "product", fallbackFactory = FeignProductRemoteServiceFallbackFactory.class) 8 | public interface FeignProductRemoteService { 9 | @RequestMapping(path = "/products/{productId}") 10 | String getProductInfo(@PathVariable("productId") String productId); 11 | } -------------------------------------------------------------------------------- /spring-cloud-example/display/src/main/java/com/elevenst/service/FeignProductRemoteServiceFallbackFactory.java: -------------------------------------------------------------------------------- 1 | package com.elevenst.service; 2 | 3 | import feign.hystrix.FallbackFactory; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class FeignProductRemoteServiceFallbackFactory implements FallbackFactory { 8 | 9 | @Override 10 | public FeignProductRemoteService create(Throwable cause) { 11 | System.out.println("t = " + cause); 12 | return productId -> "[ this product is sold out ]"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-cloud-example/display/src/main/java/com/elevenst/service/FeignProductRemoteServiceFallbackImpl.java: -------------------------------------------------------------------------------- 1 | package com.elevenst.service; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class FeignProductRemoteServiceFallbackImpl implements FeignProductRemoteService { 7 | @Override 8 | public String getProductInfo(String productId) { 9 | return "[ this product is sold out ]"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /spring-cloud-example/display/src/main/java/com/elevenst/service/ProductRemoteService.java: -------------------------------------------------------------------------------- 1 | package com.elevenst.service; 2 | 3 | public interface ProductRemoteService { 4 | String getProductInfo(String productId); 5 | } 6 | -------------------------------------------------------------------------------- /spring-cloud-example/eureka-server/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-server') 3 | testCompile('org.springframework.boot:spring-boot-starter-test') 4 | } 5 | 6 | dependencyManagement { 7 | imports { 8 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" 9 | } 10 | } -------------------------------------------------------------------------------- /spring-cloud-example/eureka-server/src/main/java/com/elevenst/eurekaserver/EurekaServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.elevenst.eurekaserver; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaServerApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-cloud-example/eureka-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8761 # Default : 8761 3 | 4 | spring: 5 | application: 6 | name: eureka-server 7 | 8 | eureka: 9 | server: 10 | response-cache-update-interval-ms: 1000 # Eureka Server's Response Cache. Default 30,000ms 11 | enableSelfPreservation: false # Just for demo 12 | client: 13 | register-with-eureka: false # Only for local stand-alone development 14 | fetch-registry: false # Only for local stand-alone development 15 | service-url: 16 | defaultZone: http://localhost:8761/eureka # Default Value. Just for demo 17 | instance: 18 | prefer-ip-address: true # Use ip address instead of hostname from OS when reporting myself to eureka server -------------------------------------------------------------------------------- /spring-cloud-example/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/spring-cloud-example/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-example/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 10 15:17:03 KST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip 7 | -------------------------------------------------------------------------------- /spring-cloud-example/product/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compile('org.springframework.boot:spring-boot-starter-web') 3 | compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client') // To use Eureka client 4 | testCompile('org.springframework.boot:spring-boot-starter-test') 5 | } 6 | 7 | dependencyManagement { 8 | imports { 9 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /spring-cloud-example/product/src/main/java/com/elevenst/ProductApplication.java: -------------------------------------------------------------------------------- 1 | package com.elevenst; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaClient 9 | public class ProductApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(ProductApplication.class); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-cloud-example/product/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8082 3 | 4 | spring: 5 | application: 6 | name: product 7 | 8 | eureka: 9 | instance: 10 | prefer-ip-address: true 11 | client: 12 | service-url: 13 | defaultZone: http://127.0.0.1:8761/eureka # default address -------------------------------------------------------------------------------- /spring-cloud-example/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'spring-cloud-workshop' 2 | include 'product' 3 | include 'display' 4 | include 'eureka-server' 5 | include 'zuul' 6 | 7 | -------------------------------------------------------------------------------- /spring-cloud-example/zuul/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compile('org.springframework.retry:spring-retry:1.2.2.RELEASE') 3 | compile('org.springframework.cloud:spring-cloud-starter-netflix-zuul') 4 | compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client') 5 | testCompile('org.springframework.boot:spring-boot-starter-test') 6 | } 7 | 8 | dependencyManagement { 9 | imports { 10 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" 11 | } 12 | } -------------------------------------------------------------------------------- /spring-cloud-example/zuul/src/main/java/com/elevenst/zuul/ZuulApplication.java: -------------------------------------------------------------------------------- 1 | package com.elevenst.zuul; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 7 | 8 | @EnableZuulProxy 9 | @EnableDiscoveryClient 10 | @SpringBootApplication 11 | public class ZuulApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(ZuulApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.3.9.RELEASE' 3 | id 'io.spring.dependency-management' version '1.0.11.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'hello' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '11' 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | dependencies { 16 | implementation 'org.springframework.boot:spring-boot-starter' 17 | testImplementation('org.springframework.boot:spring-boot-starter-test') { 18 | exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' 19 | } 20 | } 21 | 22 | test { 23 | useJUnitPlatform() 24 | } 25 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/spring-core-study/coreEx1-pojo/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'coreEx1' 2 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/src/main/java/hello/coreEx1/CoreEx1Application.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class CoreEx1Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(CoreEx1Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/src/main/java/hello/coreEx1/MemberApp.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1; 2 | 3 | import hello.coreEx1.member.Grade; 4 | import hello.coreEx1.member.Member; 5 | import hello.coreEx1.member.MemberService; 6 | 7 | public class MemberApp { 8 | public static void main(String[] args) { 9 | AppConfig appConfig = new AppConfig(); 10 | MemberService memberService = appConfig.memberService(); 11 | Member member = new Member(1L, "bobae", Grade.VIP); 12 | memberService.join(member); 13 | 14 | Member findMember = memberService.findMember(1L); 15 | System.out.println("New Member = " + member.getName()); 16 | System.out.println("Find Member = " + findMember.getName()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/src/main/java/hello/coreEx1/discount/DiscountPolicy.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.discount; 2 | 3 | import hello.coreEx1.member.Member; 4 | 5 | public interface DiscountPolicy { 6 | 7 | /** 8 | * @return 할인 대상 금액 9 | */ 10 | int discount(Member member, int price); 11 | } 12 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/src/main/java/hello/coreEx1/discount/FixDiscountPolicy.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.discount; 2 | 3 | import hello.coreEx1.member.Grade; 4 | import hello.coreEx1.member.Member; 5 | 6 | public class FixDiscountPolicy implements DiscountPolicy{ 7 | 8 | private final int discountFixAmount = 1000; 9 | 10 | @Override 11 | public int discount(Member member, int price) { 12 | if (member.getGrade() == Grade.VIP){ 13 | return discountFixAmount; 14 | } 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/src/main/java/hello/coreEx1/discount/RateDiscountPolicy.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.discount; 2 | 3 | import hello.coreEx1.member.Grade; 4 | import hello.coreEx1.member.Member; 5 | 6 | public class RateDiscountPolicy implements DiscountPolicy{ 7 | 8 | private static final int discountPercent = 10; 9 | 10 | @Override 11 | public int discount(Member member, int price) { 12 | if (member.getGrade() == Grade.VIP){ 13 | return getDiscountPrice(price); 14 | } 15 | return 0; 16 | } 17 | 18 | private int getDiscountPrice(int price) { 19 | return price * discountPercent / 100; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/src/main/java/hello/coreEx1/member/Grade.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.member; 2 | 3 | public enum Grade { 4 | BASIC, 5 | VIP 6 | } 7 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/src/main/java/hello/coreEx1/member/MemberRepository.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.member; 2 | 3 | public interface MemberRepository { 4 | void save(Member member); 5 | 6 | Member findById(Long memberId); 7 | } 8 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/src/main/java/hello/coreEx1/member/MemberService.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.member; 2 | 3 | public interface MemberService { 4 | 5 | void join(Member member); 6 | 7 | Member findMember(Long memberId); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/src/main/java/hello/coreEx1/member/MemberServiceImpl.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.member; 2 | 3 | public class MemberServiceImpl implements MemberService { 4 | 5 | private final MemberRepository memberRepository; 6 | 7 | public MemberServiceImpl(MemberRepository memberRepository) { 8 | this.memberRepository = memberRepository; 9 | } 10 | 11 | @Override 12 | public void join(Member member) { 13 | memberRepository.save(member); 14 | } 15 | 16 | @Override 17 | public Member findMember(Long memberId) { 18 | return memberRepository.findById(memberId); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/src/main/java/hello/coreEx1/member/MemoryMemberRepository.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.member; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.ConcurrentHashMap; 5 | 6 | public class MemoryMemberRepository implements MemberRepository { 7 | 8 | // Memory DB 9 | // HashMap은 동시성 이슈가 있어 현업에서는 ConcurrentHashMap을 사용한다. 10 | private static Map store = new ConcurrentHashMap<>(); 11 | 12 | @Override 13 | public void save(Member member) { 14 | store.put(member.getId(), member); 15 | } 16 | 17 | @Override 18 | public Member findById(Long memberId) { 19 | return store.get(memberId); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/src/main/java/hello/coreEx1/order/OrderService.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.order; 2 | 3 | public interface OrderService { 4 | Order createOrder(Long memberId, String itemName, int itemPrice); 5 | } 6 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-pojo/src/test/java/hello/coreEx1/CoreEx1ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class CoreEx1ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.3.9.RELEASE' 3 | id 'io.spring.dependency-management' version '1.0.11.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'hello' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '11' 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | dependencies { 16 | implementation 'org.springframework.boot:spring-boot-starter' 17 | testImplementation('org.springframework.boot:spring-boot-starter-test') { 18 | exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' 19 | } 20 | } 21 | 22 | test { 23 | useJUnitPlatform() 24 | } 25 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/spring-core-study/coreEx1-spring/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'coreEx1' 2 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/src/main/java/hello/coreEx1/CoreEx1Application.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class CoreEx1Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(CoreEx1Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/src/main/java/hello/coreEx1/discount/DiscountPolicy.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.discount; 2 | 3 | import hello.coreEx1.member.Member; 4 | 5 | public interface DiscountPolicy { 6 | 7 | /** 8 | * @return 할인 대상 금액 9 | */ 10 | int discount(Member member, int price); 11 | } 12 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/src/main/java/hello/coreEx1/discount/FixDiscountPolicy.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.discount; 2 | 3 | import hello.coreEx1.member.Grade; 4 | import hello.coreEx1.member.Member; 5 | 6 | public class FixDiscountPolicy implements DiscountPolicy{ 7 | 8 | private final int discountFixAmount = 1000; 9 | 10 | @Override 11 | public int discount(Member member, int price) { 12 | if (member.getGrade() == Grade.VIP){ 13 | return discountFixAmount; 14 | } 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/src/main/java/hello/coreEx1/discount/RateDiscountPolicy.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.discount; 2 | 3 | import hello.coreEx1.member.Grade; 4 | import hello.coreEx1.member.Member; 5 | 6 | public class RateDiscountPolicy implements DiscountPolicy{ 7 | 8 | private static final int discountPercent = 10; 9 | 10 | @Override 11 | public int discount(Member member, int price) { 12 | if (member.getGrade() == Grade.VIP){ 13 | return getDiscountPrice(price); 14 | } 15 | return 0; 16 | } 17 | 18 | private int getDiscountPrice(int price) { 19 | return price * discountPercent / 100; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/src/main/java/hello/coreEx1/member/Grade.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.member; 2 | 3 | public enum Grade { 4 | BASIC, 5 | VIP 6 | } 7 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/src/main/java/hello/coreEx1/member/MemberRepository.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.member; 2 | 3 | public interface MemberRepository { 4 | void save(Member member); 5 | 6 | Member findById(Long memberId); 7 | } 8 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/src/main/java/hello/coreEx1/member/MemberService.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.member; 2 | 3 | public interface MemberService { 4 | 5 | void join(Member member); 6 | 7 | Member findMember(Long memberId); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/src/main/java/hello/coreEx1/member/MemberServiceImpl.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.member; 2 | 3 | public class MemberServiceImpl implements MemberService { 4 | 5 | private final MemberRepository memberRepository; 6 | 7 | public MemberServiceImpl(MemberRepository memberRepository) { 8 | this.memberRepository = memberRepository; 9 | } 10 | 11 | @Override 12 | public void join(Member member) { 13 | memberRepository.save(member); 14 | } 15 | 16 | @Override 17 | public Member findMember(Long memberId) { 18 | return memberRepository.findById(memberId); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/src/main/java/hello/coreEx1/member/MemoryMemberRepository.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.member; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.ConcurrentHashMap; 5 | 6 | public class MemoryMemberRepository implements MemberRepository { 7 | 8 | // Memory DB 9 | // HashMap은 동시성 이슈가 있어 현업에서는 ConcurrentHashMap을 사용한다. 10 | private static Map store = new ConcurrentHashMap<>(); 11 | 12 | @Override 13 | public void save(Member member) { 14 | store.put(member.getId(), member); 15 | } 16 | 17 | @Override 18 | public Member findById(Long memberId) { 19 | return store.get(memberId); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/src/main/java/hello/coreEx1/order/OrderService.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1.order; 2 | 3 | public interface OrderService { 4 | Order createOrder(Long memberId, String itemName, int itemPrice); 5 | } 6 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-core-study/coreEx1-spring/src/test/java/hello/coreEx1/CoreEx1ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package hello.coreEx1; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class CoreEx1ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /springboot2-webservice/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/springboot2-webservice/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /springboot2-webservice/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /springboot2-webservice/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'springboot2-webservice' 2 | 3 | -------------------------------------------------------------------------------- /springboot2-webservice/src/main/java/com/tistory/bbdevstory/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.tistory.bbdevstory.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 | -------------------------------------------------------------------------------- /springboot2-webservice/src/main/java/com/tistory/bbdevstory/springboot/config/auth/JpaConfig.java: -------------------------------------------------------------------------------- 1 | package com.tistory.bbdevstory.springboot.config.auth; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.data.jpa.repository.config.EnableJpaAuditing; 5 | 6 | @Configuration 7 | @EnableJpaAuditing 8 | public class JpaConfig { 9 | } 10 | -------------------------------------------------------------------------------- /springboot2-webservice/src/main/java/com/tistory/bbdevstory/springboot/config/auth/LoginUser.java: -------------------------------------------------------------------------------- 1 | package com.tistory.bbdevstory.springboot.config.auth; 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: 어노테이션이 사용될 위치 9 | - ElementType.PARAMETER: 파라미터에서 사용되는 어노테이션임을 의미 10 | 11 | @interface: 어노테이션임을 의미 12 | */ 13 | @Target(ElementType.PARAMETER) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface LoginUser { 16 | } 17 | -------------------------------------------------------------------------------- /springboot2-webservice/src/main/java/com/tistory/bbdevstory/springboot/config/auth/dto/SessionUser.java: -------------------------------------------------------------------------------- 1 | package com.tistory.bbdevstory.springboot.config.auth.dto; 2 | 3 | import com.tistory.bbdevstory.springboot.domain.user.User; 4 | import lombok.Getter; 5 | 6 | import java.io.Serializable; 7 | 8 | @Getter 9 | public class SessionUser implements Serializable { 10 | // Session 저장위한 직렬화 필요 11 | private String name; 12 | private String email; 13 | private String picture; 14 | 15 | public SessionUser(User user) { 16 | this.name = user.getName(); 17 | this.email = user.getEmail(); 18 | this.picture = user.getPicture(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /springboot2-webservice/src/main/java/com/tistory/bbdevstory/springboot/domain/BaseTimeEntity.java: -------------------------------------------------------------------------------- 1 | package com.tistory.bbdevstory.springboot.domain; 2 | 3 | import lombok.Getter; 4 | import org.springframework.data.annotation.CreatedDate; 5 | import org.springframework.data.annotation.LastModifiedDate; 6 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; 7 | 8 | import javax.persistence.EntityListeners; 9 | import javax.persistence.MappedSuperclass; 10 | import java.time.LocalDateTime; 11 | 12 | @Getter 13 | @MappedSuperclass 14 | @EntityListeners(AuditingEntityListener.class) 15 | public abstract class BaseTimeEntity { 16 | @CreatedDate 17 | private LocalDateTime createdDate; 18 | 19 | @LastModifiedDate 20 | private LocalDateTime modifiedDate; 21 | } 22 | -------------------------------------------------------------------------------- /springboot2-webservice/src/main/java/com/tistory/bbdevstory/springboot/domain/posts/PostsRepository.java: -------------------------------------------------------------------------------- 1 | package com.tistory.bbdevstory.springboot.domain.posts; 2 | 3 | 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | 7 | import java.util.List; 8 | 9 | public interface PostsRepository extends JpaRepository { 10 | 11 | @Query("SELECT p FROM Posts p ORDER BY p.id DESC") 12 | List findAllDesc(); 13 | } 14 | -------------------------------------------------------------------------------- /springboot2-webservice/src/main/java/com/tistory/bbdevstory/springboot/domain/user/Role.java: -------------------------------------------------------------------------------- 1 | package com.tistory.bbdevstory.springboot.domain.user; 2 | 3 | import lombok.Getter; 4 | import lombok.RequiredArgsConstructor; 5 | 6 | @Getter 7 | @RequiredArgsConstructor 8 | public enum Role { 9 | 10 | // Spring security 에서는 key 값 앞에 ROLE_ 이 붙어야 한다. 11 | GUEST("ROLE_GUEST", "손님"), 12 | USER("ROLE_USER", "일반 사용자"); 13 | 14 | private final String key; 15 | private final String title; 16 | } 17 | -------------------------------------------------------------------------------- /springboot2-webservice/src/main/java/com/tistory/bbdevstory/springboot/domain/user/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.tistory.bbdevstory.springboot.domain.user; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import java.util.Optional; 6 | 7 | public interface UserRepository extends JpaRepository { 8 | Optional findByEmail(String email); 9 | } 10 | -------------------------------------------------------------------------------- /springboot2-webservice/src/main/java/com/tistory/bbdevstory/springboot/web/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.tistory.bbdevstory.springboot.web; 2 | 3 | import com.tistory.bbdevstory.springboot.web.dto.HelloResponseDto; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RequestParam; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | public class HelloController { 10 | @GetMapping("/hello") 11 | public String hello(){ 12 | return "Hello"; 13 | } 14 | 15 | @GetMapping("/hello/dto") 16 | public HelloResponseDto helloDto(@RequestParam("name") String name, 17 | @RequestParam("amount") int amount){ 18 | return new HelloResponseDto(name, amount); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /springboot2-webservice/src/main/java/com/tistory/bbdevstory/springboot/web/dto/HelloResponseDto.java: -------------------------------------------------------------------------------- 1 | package com.tistory.bbdevstory.springboot.web.dto; 2 | 3 | import lombok.Getter; 4 | import lombok.RequiredArgsConstructor; 5 | 6 | @Getter 7 | @RequiredArgsConstructor 8 | public class HelloResponseDto { 9 | private final String name; 10 | private final int amount; 11 | } 12 | -------------------------------------------------------------------------------- /springboot2-webservice/src/main/java/com/tistory/bbdevstory/springboot/web/dto/PostsListResponseDto.java: -------------------------------------------------------------------------------- 1 | package com.tistory.bbdevstory.springboot.web.dto; 2 | 3 | import com.tistory.bbdevstory.springboot.domain.posts.Posts; 4 | import lombok.Getter; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | @Getter 9 | public class PostsListResponseDto { 10 | private Long id; 11 | private String title; 12 | private String author; 13 | private LocalDateTime modifiedDate; 14 | 15 | public PostsListResponseDto(Posts entity){ 16 | this.id = entity.getId(); 17 | this.title = entity.getTitle(); 18 | this.author = entity.getAuthor(); 19 | this.modifiedDate = entity.getModifiedDate(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /springboot2-webservice/src/main/java/com/tistory/bbdevstory/springboot/web/dto/PostsResponseDto.java: -------------------------------------------------------------------------------- 1 | package com.tistory.bbdevstory.springboot.web.dto; 2 | 3 | import com.tistory.bbdevstory.springboot.domain.posts.Posts; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public class PostsResponseDto { 8 | private Long id; 9 | private String title; 10 | private String content; 11 | private String author; 12 | 13 | public PostsResponseDto(Posts entity){ 14 | this.id = entity.getId(); 15 | this.title = entity.getTitle(); 16 | this.content = entity.getContent(); 17 | this.author = entity.getAuthor(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /springboot2-webservice/src/main/java/com/tistory/bbdevstory/springboot/web/dto/PostsUpdateRequestDto.java: -------------------------------------------------------------------------------- 1 | package com.tistory.bbdevstory.springboot.web.dto; 2 | 3 | import lombok.Builder; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Getter 8 | @NoArgsConstructor 9 | public class PostsUpdateRequestDto { 10 | private String title; 11 | private String content; 12 | 13 | @Builder 14 | public PostsUpdateRequestDto(String title, String content){ 15 | this.title = title; 16 | this.content = content; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /springboot2-webservice/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # db 2 | spring.jpa.show-sql=true 3 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect 4 | spring.h2.console.enabled=true 5 | 6 | # session db 7 | spring.session.store-type=jdbc 8 | 9 | # application-oauth 추가 10 | spring.profiles.include=oauth 11 | 12 | # devtools 13 | spring.devtools.livereload.enabled=true -------------------------------------------------------------------------------- /springboot2-webservice/src/main/resources/templates/layout/footer.mustache: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /springboot2-webservice/src/main/resources/templates/layout/header.mustache: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 스프링부트 웹서비스 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /springboot2-webservice/src/test/java/com/tistory/bbdevstory/springboot/web/dto/HelloResponseDtoTest.java: -------------------------------------------------------------------------------- 1 | package com.tistory.bbdevstory.springboot.web.dto; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.assertj.core.api.Assertions.assertThat; 6 | 7 | public class HelloResponseDtoTest { 8 | @Test 9 | public void lombok_function_test(){ 10 | //given 11 | String name = "test"; 12 | int amount = 1000; 13 | 14 | //when 15 | HelloResponseDto dto = new HelloResponseDto(name, amount); 16 | 17 | // then 18 | assertThat(dto.getName()).isEqualTo(name); 19 | assertThat(dto.getAmount()).isEqualTo(amount); 20 | 21 | // Test 가 통과된다면, lombok - Getter, RequiredArgsConstructor 가 잘 작동한다는 것이 증명되는 것 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /springboot2-webservice/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | # db 2 | spring.jpa.show-sql=true 3 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect 4 | spring.h2.console.enabled=true 5 | 6 | # session db 7 | spring.session.store-type=jdbc 8 | 9 | # Test OAuth 10 | spring.security.oauth2.client.registration.google.client-id=test 11 | spring.security.oauth2.client.registration.google.client-secret=test 12 | spring.security.oauth2.client.registration.google.scope=profile,email -------------------------------------------------------------------------------- /webclient/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /webclient/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/webclient/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /webclient/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /webclient/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'webclient' 2 | -------------------------------------------------------------------------------- /webclient/src/main/java/com/practice/webclient/jsonplace/config/WebClientConfig.java: -------------------------------------------------------------------------------- 1 | package com.practice.webclient.jsonplace.config; 2 | 3 | import com.practice.webclient.jsonplace.service.JsonPlaceWebClient; 4 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @EnableConfigurationProperties(WebClientProperty.class) 9 | @Configuration 10 | public class WebClientConfig { 11 | @Bean 12 | public JsonPlaceWebClient jsonPlaceWebClient(WebClientProperty webClientProperty) { 13 | return new JsonPlaceWebClient(webClientProperty); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /webclient/src/main/java/com/practice/webclient/jsonplace/config/WebClientProperty.java: -------------------------------------------------------------------------------- 1 | package com.practice.webclient.jsonplace.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | 6 | @Data 7 | @ConfigurationProperties(prefix = "base") 8 | public class WebClientProperty { 9 | private String uri; 10 | private String token; 11 | } 12 | -------------------------------------------------------------------------------- /webclient/src/main/java/com/practice/webclient/jsonplace/dto/JsonPlaceResponse.java: -------------------------------------------------------------------------------- 1 | package com.practice.webclient.jsonplace.dto; 2 | 3 | public interface JsonPlaceResponse { 4 | } 5 | -------------------------------------------------------------------------------- /webclient/src/main/java/com/practice/webclient/jsonplace/dto/UserPostResponse.java: -------------------------------------------------------------------------------- 1 | package com.practice.webclient.jsonplace.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.ToString; 7 | 8 | @ToString 9 | @NoArgsConstructor 10 | @AllArgsConstructor 11 | @Getter 12 | public class UserPostResponse implements JsonPlaceResponse { 13 | private Long userId; 14 | private Long postId; 15 | private String title; 16 | private String body; 17 | } 18 | -------------------------------------------------------------------------------- /webclient/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | base: 2 | uri: "https://jsonplaceholder.typicode.com/posts" 3 | token: "${SITE_API_TOKEN}" -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/docker/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | db: 4 | image: mysql:5.7 5 | platform: linux/x86_64 6 | restart: always 7 | ports: 8 | - "3306:3306" 9 | environment: 10 | MYSQL_ROOT_PASSWORD: admin 11 | MYSQL_USER: user 12 | MYSQL_PASSWORD: user 13 | TZ: Asia/Seoul 14 | volumes: 15 | - ./data:/docker-entrypoint-initdb.d -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KimDoubleB/spring-learning/db9604b1c766301924051c12af937d90e6ae8bc3/webflux-r2dbc-mysql/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'demo' 2 | -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/src/main/java/com/example/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 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 | -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/src/main/java/com/example/demo/application/UserService.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.application; 2 | 3 | import com.example.demo.application.dto.UserResponse; 4 | import com.example.demo.domain.user.UserRepository; 5 | import lombok.RequiredArgsConstructor; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.transaction.annotation.Transactional; 8 | import reactor.core.publisher.Mono; 9 | 10 | import java.util.List; 11 | 12 | @Service 13 | @Transactional(readOnly = true) 14 | @RequiredArgsConstructor 15 | public class UserService { 16 | 17 | private final UserRepository userRepository; 18 | 19 | public Mono> getAll() { 20 | return userRepository.findAllWithPosts() 21 | .map(UserResponse::from) 22 | .collectList(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/src/main/java/com/example/demo/application/dto/PostResponse.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.application.dto; 2 | 3 | import com.example.demo.domain.post.Post; 4 | 5 | import java.time.LocalDateTime; 6 | 7 | public record PostResponse(Long id, String title, String content, 8 | LocalDateTime createdAt, LocalDateTime updatedAt) { 9 | public static PostResponse from(Post post) { 10 | return new PostResponse(post.getId(), 11 | post.getTitle(), 12 | post.getContent(), 13 | post.getCreatedAt(), 14 | post.getUpdatedAt()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/src/main/java/com/example/demo/application/dto/PostResponseWithUser.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.application.dto; 2 | 3 | import com.example.demo.domain.post.Post; 4 | 5 | import java.time.LocalDateTime; 6 | 7 | public record PostResponseWithUser(Long id, String title, String content, LocalDateTime createdAt, 8 | Long authorId, String authorName, Integer authorAge) { 9 | public static PostResponseWithUser from(Post post) { 10 | return new PostResponseWithUser(post.getId(), 11 | post.getTitle(), 12 | post.getContent(), 13 | post.getCreatedAt(), 14 | post.getAuthor().getId(), 15 | post.getAuthor().getName(), 16 | post.getAuthor().getAge()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/src/main/java/com/example/demo/application/dto/SavePostRequest.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.application.dto; 2 | 3 | import com.example.demo.domain.post.Post; 4 | 5 | public record SavePostRequest(Long authorId, String title, String content) { 6 | 7 | public Post toEntity() { 8 | return new Post(title, content, authorId); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/src/main/java/com/example/demo/application/dto/UserResponse.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.application.dto; 2 | 3 | import com.example.demo.domain.user.User; 4 | 5 | import java.time.LocalDateTime; 6 | import java.util.List; 7 | 8 | public record UserResponse(Long id, String name, Integer age, LocalDateTime createdAt, List posts) { 9 | 10 | public static UserResponse from(User user) { 11 | var posts = user.getPosts().stream() 12 | .map(PostResponse::from).toList(); 13 | return new UserResponse(user.getId(), 14 | user.getName(), 15 | user.getAge(), 16 | user.getCreatedAt(), 17 | posts); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/src/main/java/com/example/demo/domain/post/PostCustomRepository.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.domain.post; 2 | 3 | import reactor.core.publisher.Flux; 4 | 5 | public interface PostCustomRepository { 6 | 7 | Flux searchByKeyword(String keyword); 8 | 9 | Flux findAllWithAuthor(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/src/main/java/com/example/demo/domain/post/PostUserSpecificInfo.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.domain.post; 2 | 3 | import lombok.Builder; 4 | 5 | import java.time.LocalDateTime; 6 | 7 | @Builder 8 | public record PostUserSpecificInfo(Long postId, String title, String content, LocalDateTime postCreatedAt, 9 | Long authorId, String authorName, Integer authorAge) { 10 | } 11 | -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/src/main/java/com/example/demo/domain/user/UserCustomRepository.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.domain.user; 2 | 3 | import reactor.core.publisher.Flux; 4 | 5 | public interface UserCustomRepository { 6 | 7 | Flux findAllWithPosts(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/src/main/java/com/example/demo/domain/user/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.domain.user; 2 | 3 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 4 | 5 | public interface UserRepository extends ReactiveCrudRepository, UserCustomRepository { 6 | } 7 | -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | r2dbc: 3 | url: r2dbc:pool:mysql://localhost:3306/webflux 4 | username: user 5 | password: user 6 | logging: 7 | level: 8 | org.springframework.r2dbc.core: debug -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/src/test/java/com/example/demo/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 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 | -------------------------------------------------------------------------------- /webflux-r2dbc-mysql/src/test/java/com/example/demo/domain/user/UserCustomRepositoryImplTest.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.domain.user; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import java.util.List; 6 | 7 | import static org.junit.jupiter.api.Assertions.*; 8 | 9 | class UserCustomRepositoryImplTest { 10 | 11 | @Test 12 | void name() { 13 | var of = List.of(); 14 | var strings = of.stream() 15 | .map(a -> a.toString()) 16 | .toList(); 17 | System.out.println("strings = " + strings); 18 | } 19 | } --------------------------------------------------------------------------------