Back End/Spring Boot 6

스프링 부트 스케줄러 @Scheduled 어노테이션 사용법(@Scheduled Annotation)

@Scheduled 사용법에 대해 소스 예제를 들어 설명하겠습니다. 1. @EnableScheduling 추가 1) @SpringBootApplication에 선언 package me.rooted.schedule; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.scheduling.annotation.EnableScheduling; @EnableScheduling @SpringBootApplication public class SpringSchedulerApplication { public s..

Spring Boot 프로젝트 구조

Spring Boot 프로젝트를 생성하며 많은 고민이 드는 것이 프로젝트 구조입니다. 어떻게해야 좋을지 모르겠다면, 이 글을 참고해주세요. 이 글에서는 크게 2가지의 구조를 설명드립니다. 1. 역할별로 묶기 - spring-boot-project - src/main/java - me.rooted └ SpringBootProjectApplication.java - me.rooted.config └ SwaggerConfig.java └ WebSecurityConfig.java - me.rooted.controller └ BoardController.java └ AccountController.java - me.rooted.domain └ BoardVO.java └ AccountVO.java - me.root..

Spring Boot 원리 : 자동 설정(Auto Configuration)

이 글은 인프런의 백기선님의 강좌를 수강하며 정리한 글입니다. Spring Boot의 자동 설정 기능에 대해 알아보자. 1. @SpringBootApplication 먼저 프로젝트를 생성한 후 기본 패키지 아래 *Application.java의 @SpringBootApplication을 확인한다. @SpringBootApplication의 세부코드로 들어가면 아래의 애노테이션이 선언되어 있다. @ComponentScan @EnableAutoConfiguration 2. @ComponentScan @Component @Configuration @Repository @Service @Controller @RestController @ComponentScan은 선언된 패키지를 포함한 하위 패키지의 Compon..

Spring Boot 원리 : 의존성(Dependency) 관리

이 글은 인프런의 백기선님의 강좌를 수강하며 정리한 글입니다. 1. 서론 예전 Spring Legacy Project의 경우 스프링 프레임워크의 버전업이든지, 써드파티의 버전업이든지 서로간의 의존성 충돌이 일어나기 시작하면 해결하는데 시간이 꽤 걸린다. 어떻게 해서 Spring Boot(이하 스프링 부트)는 어떻게 버전 명시 없이 의존성이 주입되는 것일까? 우선 스프링 부트 프로젝트의 pom.xml을 살펴봅시다. 2. Parent : Dependency Management + Resource Filtering + Plugin Configuration pom.xml(Maven) org.springframework.boot spring-boot-starter-parent 2.1.7.RELEASE 간단하게도,..

간단한 스프링 스케줄러(Spring Scheduler) 사용하기 : @Scheduled Annotation

Spring Quartz 없이 간단하게 스케줄러를 사용해보자. 1. @EnableScheduling package me.rooted.mail; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.scheduling.annotation.EnableScheduling; @EnableScheduling @SpringBootApplication public class SpringMailThymeleafApplication { public static void main(String[] args) { Spr..

Spring Boot 메일 전송 : Spring Boot 2, Mail, Thymeleaf

Spring Boot 2.x 기준 Mail Send Client를 간단히 소개해봅니다. 기 프로젝트에 적용하실 분들은 1-2로, 신규 프로젝트로 진행하실 분들은 1-1로 봐주시면 되겠습니다.1-1. 프로젝트 생성 1-2. Maven dependency(pom.xml) 설정 org.springframework.boot spring-boot-starter-mail org.springframework.boot spring-boot-starter-thymeleaf 2. 프로젝트 구조 3. src/main/resources/application.properties 설정## thymeleaf default settingsspring.thymeleaf.prefix=classpath:/templates/spri..