728x90 Spring24 spring static 경로 404 SwaggerConfig에 추가된 @EnableWebMvc 어노테이션이 원인이었다. 해당 어노테이션 사용시 따로 추가해줘야한다 package com.zeroback.aboutme.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframewo.. 2022. 8. 10. spring responsebody json 필드명 변경하기 memberId -> member_id 로 변경 public class LoginResultDto { @JsonProperty("member_id") Long memberId; String email; } 2022. 8. 2. jpa @GeneratedValue 기본키 매핑 어노테이션 @Id에 대하여 직접 할당할 땐 @Id만 사용하고, @Id가 선언된 필드에 기본키 값을 자동으로 할당할 때 @GeneratedValue 사용 자동생성은 객체 생성 뒤 직접 코드로 setId()안해줘도 JPA가 알아서 값을 id에 넣어준다는 것이다. @GeneratedValue 전략 (사용예 : @GeneratedValue(starategy = GenerationType.IDENTITY) IDENTITY 전략의 특징 - 기본키 생성을 데이터베이스에 위임하고 주로 MySQL, SQL Server, DB2에서 사용 - 예를 들자면 MySQL을 사용한다면 auto_increment로 지정해서 DDL을 만든다. 1차 캐시에는 @Id와 @Entity로 지정한 것들이 들어간다. 그런데 기본키의.. 2022. 4. 16. spring rabbitMQ 사용 https://www.cloudamqp.com/ CloudAMQP - RabbitMQ as a Service CloudAMQP - industry leading RabbitMQ as a service Start your managed cluster today. CloudAMQP is 100% free to try. www.cloudamqp.com 클라우드 rabbitMQ 사용 해당 port 1883 사용하면 안됨 디폴트 port 사용 application.yml 설정 Cloud rabbitMQ 사용하면 vhost 해줘야하고 default port는 5672 rabbitmq: host: dingo.rmq.cloudamqp.com username: ulnwlrwi password: 1-xzf7tfUz4szU.. 2022. 4. 16. Spring Gradle 빌드 (인텔리제이 방법 포함) 우측 Graddle -> 프로젝트 -> Tasks -> build -> build 클릭 [터미널로 빌드] gradlew 유닉스용 실행 스크립트이다. > gradle build 위와 같이 하면 로컬에 설치된 gradle을 사용. 이 경우에 Java나 Gradle이 설치되어 있어야하고, 새로받은 프로젝트의 Gradle 버전과 로컬에 설치된 Gradle 버전이 호환되지 않으면 문제가 발생할 수 있다. > ./gradlew build 위와 같이 하면 Gradle Wrapper를 사용해서 위에서 언급한 문제가 발생하지 않는다. 참고 https://jobc.tistory.com/202 Gradle & Build 그리고 IntelliJ의 Build gradle을 알아보기 전에 컴파일, 빌드의 개념을 알아보자 컴파일과.. 2022. 4. 10. SpringBoot Eureka 서버 설정 설정 build.gradle dependencies { implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server' implementation 'com.sun.jersey.contribs:jersey-apache-client4:1.19.4' testImplementation 'org.springframework.boot:spring-boot-starter-test' } 설정 @EableEurekaServer 설정 application.yml server: port: 8761 eureka: instance: hostname: localhost client: # 해당 두 속서은 유레카와 성호작용하는 방법을 알려주기 .. 2022. 3. 25. 스프링 시큐리티 OAuth 2.0 https://loosie.tistory.com/300 [Spring] 스프링으로 OAuth2 로그인 구현하기1 - 구글 스프링 시큐리티와 스프링 시큐리티 OAuth2 클라이언트 많은 서비스에서 로그인 기능을 id/password 방식 보다는 써드파티 방식으로 구글, 네이버과 같은 소셜 로그인 기능을 사용한다. 이는 서비스 loosie.tistory.com 참고 그대로 따라 했는데 Thread 에러남 (HttpSession) 빈 등록 후 해결 @Bean public RequestContextListener requestContextListener(){ return new RequestContextListener(); } 2022. 3. 17. 스프링 Rest Template RestTemplate restTemplate = new RestTemplate(); HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.set("myheader",token); HttpEntity request = new HttpEntity(payload, httpHeaders); ResponseEntity response = restTemplate.postForEntity(dppURI + "/api/pay/full", request, String.class); return response; 2022. 3. 16. Spring Swagger에서 Pageable 사용 Swagger 에서 Pageable 이용하기 @RequestMapping("/stores") @Api(tags = "store") @RestController public class StoreController { @ApiOperation(value = "메뉴 조회 with paging", notes="store의 id를 이용하여 가맹점의 메뉴를 페이징 처리하여 조회합니다.") @GetMapping(value="/{storeId}/menus") public Map findAllMenuByMenuId(@ApiParam(name="storeId", value="store 테이블 id", required=true) @PathVariable("storeId") long storeId, @PageableDefau.. 2022. 3. 7. Spring Data Jpa repository 통합 @Repsository 어노테이션 안 붙여줘도 빈 등록한다. 2022. 2. 23. InitDB 하는 법 package com.danal.chatting.util; import com.danal.chatting.Role.Role; import com.danal.chatting.entity.Authority; import com.danal.chatting.entity.member.Member; import com.danal.chatting.member.service.MemberService; import lombok.RequiredArgsConstructor; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Component; import javax.annotation.. 2022. 2. 22. Spring HTTPS 설정 인증서 생성 keytool -genkeypair -alias ssafy -keyalg RSA -keysize 2048 -storetype PKCS12 -keystore ssafy.p12 -validity 3650 keytool -export -alias ssafy -keystore ssafy.p12 -rfc -file ssafy.cer keytool -import -alias ssafy -file ssafy.cer -keystore ssafy.ts 모든 패스워드 설정을 123456으로 해줌 server: port: 8443 ssl: enabled: true key-store-type: PKCS12 key-store: classpath:keystore/ssafy.p12 key-store-password: .. 2022. 1. 18. spring security WebIgnore @Override public void configure(WebSecurity web) throws Exception { web.ignoring().requestMatchers(PathRequest.toStaticResources().atCommonLocations()); } 2021. 12. 3. spring security user생성 inMemory 방식 user 생성 package io.security.corespringsecurity.security.configs; import org.springframework.context.annotation.Bean; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecur.. 2021. 12. 3. spring security 필터 다중 설정 @Order로 순서 설정 package io.security.basicsecurity; import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configur.. 2021. 12. 2. spring security csrfFilter 2021. 12. 2. spring security 예외처리 package io.security.basicsecurity; import org.springframework.context.annotation.Configuration; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.anno.. 2021. 12. 2. spring security 인가 antMatcher(경로) 생략하면 모든경로 권한 확인한다. 2021. 12. 1. spring security 세션 package io.security.basicsecurity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configura.. 2021. 12. 1. spring security Remember Me 인증 package io.security.basicsecurity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configura.. 2021. 11. 30. spring security logout package io.security.basicsecurity; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.s.. 2021. 11. 30. spring security Form Login 2021. 11. 29. spring security 기본설정 @EnableWebSecurity, WebSecurityConfigurerAdapter 등록 필수!! package io.security.basicsecurity; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.W.. 2021. 11. 29. 스프링 AOP AOP 주요 용어 용어 의미 Joinpoint Advic를 적용 가능한 지점을 의미, 메소드 호출 필드 값 변경등이 Joinpoin에 해당 PointCut Joinpoint의 부분집합, 실제로 Advice가 적용되는 Joinpoint를 나타낸다. 스프링에서는 정규 표현식이자 AspectJ의 문접을 이용하여 Pointcut을 정의 Advice 언제 공통 관심 기능을 핵심 로직에 적용할 지를 정의. 메서드를 호출하기 전에 트랜잭션 시작(공통 기능) 지능을 적용한다는것을 정의하고 있다. Weaving Adivce를 핵심 로직 코드에 적용한다는 것을 Weaving이라고 한다. Aspect 여러 객체에 공통으로 적용되는 기능. 트랜잭션이나 보안등이 Aspect의 좋은 예이다. 세 가지 Weaving 방식 1. 컴.. 2021. 8. 3. 이전 1 다음 728x90