본문 바로가기

프로그래밍/Spring

(44)
[Spring] 스프링에서 @component @service @bean의 차이 객체를 생성하는 방법을 정의합니다. 하지만 세 개의 어노테이션은 서로 다른 용도와 제약 조건을 가지고 있습니다. @Component @Component는 스프링에서 관리되는 모든 빈 객체에 대한 범용적인 어노테이션입니다. @Component 어노테이션이 붙은 클래스는 스프링 컨테이너에 빈으로 등록됩니다. @Component 어노테이션은 다른 특수한 어노테이션인 @Service, @Repository, @Controller 등을 대신하여 사용될 수 있습니다. @Service @Service는 @Component와 비슷한 역할을 수행하지만, 비즈니스 로직을 처리하는 서비스 계층에 대한 어노테이션입니다. @Service 어노테이션이 붙은 클래스는 스프링 컨테이너에 빈으로 등록됩니다. @Service 어노테이션..
[Spring] application.yml에서 applcation-local.yml로 분기처리하기 [변경전] application.yml spring : datasource : url: 'jdbc:mysql://localhost:3306/house?autoReconnect=true&allowPublicKeyRetrieval' username : root password : XXXXXXXXXXX driver-class-name : org.mariadb.jdbc.Driver devtools: restart: enabled: false ________________________________________________________________________ [변경후] application.yml spring : profiles: active: dev ___________________________..
[Spring] ControllerAdvice와 RestControllerAdvice ㅇRestControllerAdvice : @ResponseBody가 붙어 있어 응답을 Json으로 내려준다는 점에서 다르다 ㅇControllerAdvice : 그렇지 않음 https://mangkyu.tistory.com/205
[Spring] 인터셉터를 이용해 로그인 상태 체크 하기 [1] WebMvcConfigurer을 상속받은 클래스 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 @Configuration @EnableWebMvc public class WebConfig implements WebMvcConfigurer { @Autowired private MyInterceptor myInterceptor; //로그인 체크 페턴 private String[] includedUrlPatterns = { "/mypage/**" }; //로그인 체크 예외 private String[] excludedUrlPatterns..
[Spring] 오류 : The request was rejected because the URL contained a potentially malicious String https://dandev.tistory.com/entry/%EB%94%94%EB%B2%84%EA%B9%85-The-request-was-rejected-because-the-URL-contained-a-potentially-malicious-String-%EC%97%90%EB%9F%AC-%EB%94%94%EB%B2%84%EA%B9%85%ED%95%98%EB%8A%94-%EB%B2%95
[Spring] 에러페이지 설정하기 에러페이지 설정하기 ( ErrorController 상속받아서 ) https://dev-jwblog.tistory.com/47
[Spring] @ControllerAdvice, @ExceptionHandler로 익셉션 처리하기 https://velog.io/@midas/Exception-%EC%B2%98%EB%A6%AC-%EB%B0%A9%EB%B2%95 [다른 예제 소스] @RestControllerAdvice @Slf4j public class ExceptionAdvice { //private final MessageSource messageSource; @ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) protected ServerErrorResponse defaultException(HttpServletRequest request, Exception e) { log.error("Unknown server error. UR..
[Spring] RestTemplate 으로 POST 전송시에 파라미터(application/x-www-form-urlencoded)로 메시지 보내기 MultiValueMap으로 맵핑시켜서 전송하면 된다 출처 : https://sejoung.github.io/2019/12/2019-12-10-RestTemplet_POST_form/#RestTemplate-%EC%9C%BC%EB%A1%9C-POST-%EC%A0%84%EC%86%A1%EC%8B%9C%EC%97%90-%ED%8C%8C%EB%9D%BC%EB%AF%B8%ED%84%B0-application-x2F-x-www-form-urlencoded-%EB%A1%9C-%EB%A9%94%EC%8B%9C%EC%A7%80-%EB%B3%B4%EB%82%B4%EA%B8%B0