spring boot
-
Spring boot JUnit test 시 field 값 배정하기 ( @Value )카테고리 없음 2022. 10. 7. 20:03
https://stackoverflow.com/questions/23162777/how-do-i-mock-an-autowired-value-field-in-spring-with-mockito How do I mock an autowired @Value field in Spring with Mockito? I'm using Spring 3.1.4.RELEASE and Mockito 1.9.5. In my Spring class I have: @Value("#{myProps['default.url']}") private String defaultUrl; @Value("#{myProps['default.password']}") private String stackoverflow.com @ExtendWith(M..
-
Spring boot Entity test codeComputer Science/Spring boot 2022. 10. 7. 01:19
@NoArgsConstructor @Entity @Getter @Table(name = "lof_user") @TypeDef(name = "json", typeClass = JsonStringType.class) public class UserEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private Long userId; @NotNull @Column(name = "token") private String fcmToken; @NotNull @Column(name = "email") private String email; @NotNull @Column(name = "nickname") privat..
-
Spring boot DB 한글 깨짐 현상Computer Science/Spring boot 2022. 10. 6. 23:45
spring: config: activate: on-profile: localDB jpa: hibernate: ddl-auto: create-drop datasource: url: jdbc:mariadb://localhost:3306/lof?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC username: root password: 1234 ?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC 위처럼 utf8을 사용한다는 것을 추가해주면 된다. 뒤의 serverTimezone은 안전을 위해 넣어주면 좋다.(UTC로 통일)
-
Spring boot api test codeComputer Science/Spring boot 2022. 10. 6. 14:44
json을 포함하여 body를 받아야하는 post api로 test를 하겠다. test를 진행할 controller 이다. package com.lof.lofserver.controller.user; import com.lof.lofserver.controller.user.request.UserInfoDto; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/v1/user") public class UserController { @PostMapping("/create") public ResponseEntity create..
-
Spring boot 와 Spring의 차이Computer Science/Spring boot 2022. 10. 5. 17:43
본 내용은 김영한님의 스프링 핵심원리 강의를 보고 작성하였습니다. https://www.inflearn.com/course/%EC%8A%A4%ED%94%84%EB%A7%81-%ED%95%B5%EC%8B%AC-%EC%9B%90%EB%A6%AC-%EA%B8%B0%EB%B3%B8%ED%8E%B8/dashboard 스프링 핵심 원리 - 기본편 - 인프런 | 강의 스프링 입문자가 예제를 만들어가면서 스프링의 핵심 원리를 이해하고, 스프링 기본기를 확실히 다질 수 있습니다., - 강의 소개 | 인프런... www.inflearn.com Spring boot 는 Spring framwork를 편리하게 사용할 수 있게 해준다. 이제는 spring 을 spring boot를 통해서만 이용한다고 해도 과언이 아니다. sp..
-
Spring boot 비동기 처리 (Aysnc)Computer Science/Spring boot 2022. 9. 29. 14:24
비동기 처리의 thread 수 등을 설정 할 config 파일을 만들어준다. package com.server.pandascore.config; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.AsyncConfigurerSupport; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import java.util.concurrent.Executor; @Configura..
-
spring boot 에서 JWT 사용하기.Computer Science/Spring boot 2022. 9. 4. 18:43
JWT란 Json Web Token의 약자로 token방식의 인증을 할 때 사용한다. Jwt를 사용하는 이유로는 1. Token을 client에서 저장하기 때문에 서버에서 관리할 필요가 없어 서버의 확장성에 용이하다. 2. 무결성이 장점으로 토큰을 HMAC(Hash-based Message Authentication) 기법으로 발급하기에 토큰의 정보를 변경하는 행위가 불가능하다. 하여 보안적인 측면에서 client가 변조된 값으로 server에 접근하기 어렵다. JWT는 크게 3가지로 구성이 되어있는데 aaaa.bbbb.cccc (header).(payload).(signature) 로 구성되어있다. header Token의 타입과 Hash알고리즘을 지정하는 정보를 가지고 있다. { "typ":"JWT"..
-
spring boot datadog json으로 log 남기기.Computer Science/Spring boot 2022. 8. 5. 16:31
datadog.yaml에서 log 기능을 우선 enable 해준다. /etc/datadog-agent/datadog.yaml 에 대부분 위치해 있다. logs_enabled: true 로 변경 해준뒤 저장하고, datadog-agent/con.d 에 java.yaml 파일을 만들어준다. #Log section logs: - type: file path: "/path/to/your/java/log.log" service: java source: java sourcecategory: sourcecode # For multiline logs, if they start by the date with the format yyyy-mm-dd uncomment the following processing rule #..