Spring
-
Spring Batch로 대용량 작업 처리하기Spring 2024. 8. 5. 17:46
문제 상황Scoop이라는 프로젝트에 매일 오전 6시와 12시에 네이버 뉴스 기사를 크롤링하는 로직이 있다. 이때, 크롤링한 뉴스를 요약까지 해야했고, 요약에는 GPT API를 사용했다. 또한, 이러한 GPT API는 FastAPI에 구현하여, 다른 서버에 존재한다. 간단한 흐름은 다음과 같다. 1. 네이버 뉴스의 각 카테고리의 뉴스들의 URL을 크롤링한다.2. 크롤링한 뉴스 URL을 사용하여 뉴스 본문을 크롤링한다.3. 크롤링한 뉴스 본문 내용 메시지를 publish 한다.4. FastAPI 서버에서 해당 메시지를 consume하여 뉴스 내용을 요약한다.5. 요약된 뉴스 내용 메시지를 publish 한다.6. Spring 서버에서 메시지를 consume하여 요약된 뉴스 내용을 DB에 저장한다. 하지만 위..
-
[트러블 슈팅] @InjectMocks @Mock vs. @Autowired @MockBeanSpring 2024. 6. 17. 06:42
단위 테스트를 구현하다가 아래와 같은 오류를 만났다.com.rollthedice.backend.domain.news.exception.NewsNotFoundException: 뉴스를 찾지 못했습니다. at java.base/java.util.Optional.orElseThrow(Optional.java:403) at com.rollthedice.backend.domain.news.service.NewsService.getDetailNews(NewsService.java:75) at ⬇️ 오류 로그 전체더보기com.rollthedice.backend.domain.news.exception.NewsNotFoundException: 뉴스를 찾지 못했습니다. at java.base/java.util.Optio..
-
Github Actions + Git Submodule로 application.yml 관리하기Spring 2024. 4. 10. 04:19
Scoop 프로젝트를 하며 Spring의 application-dev.yml 코드의 여러 키값들을 공개하지 않아야 했다. 그래서 처음에 각 값들을 secrets에 저장해서 사용하는 방식을 선택했다. 그랬더니 아래와 같은 코드가.. 되었다. env: spring.datasource.driver-class-name: ${{ secrets.DRIVER_CLASS_NAME }} spring.datasource.url: ${{ secrets.DATASOURCE_URL }} spring.datasource.username: ${{ secrets.DATABASE_USERNAME }} spring.datasource.password: ${{ ..
-
[Spring Security] kakao 소셜 로그인Spring 2023. 11. 21. 01:12
카카오 소셜 회원가입 & 로그인 SpringSecurity + OAuth2 사용자 정보(이메일, 이름, 프로필 사진) 받아와서 DB에 저장하기 (H2사용) https://developers.kakao.com/docs/latest/ko/kakaologin/rest-api#:~:text=Request-,https%3A//kauth.kakao.com/oauth/authorize,-%3Fresponse_type%3Dcode%26client_id Kakao Developers 카카오 API를 활용하여 다양한 어플리케이션을 개발해보세요. 카카오 로그인, 메시지 보내기, 친구 API, 인공지능 API 등을 제공합니다. developers.kakao.com https://developers.kakao.com/docs/..
-
Event Publisher / Event ListenerSpring 2023. 7. 4. 03:24
사용 이유: 의존성 줄이기 위함 Spring Event 구성 Event Class Event Publisher Event Listener Event Class public class OrderedEvent { private String productName; public OrderedEvent(String productName) { this.productName = productName; } public String getProductName() { return productName; } } Event Publisher @Slf4j @Service public class OrderService { ApplicationEventPublisher publisher; public OrderService(App..
-
[Test Code] @NotBlank 테스트 코드 작성 방법Spring 2023. 7. 3. 00:12
검사하고 싶은 Entity @Getter @Embeddable @NoArgsConstructor public class NotificationContent { @NotBlank(message = "notification content must not be blank") @Column(nullable = false) private String content; public NotificationContent(String content) { this.content = content; } } @NotBlank test code @SpringBootTest class NotificationContentTest { private Validator validator = null; @BeforeEach public v..
-
[Banana] 명함 지갑 - 카테고리별 명함 전체 조회Spring/Banana 2023. 6. 25. 06:30
접속 경로 GET http://localhost:8080/banana/wallet/categories/{categoryId} 로그인 토큰 넣기 { "storedCards": [ { "name": "Ashley", "isBookmarked": true, "cid": 29, "cardContentResponses": [ { "cid": 56, "content": "Marlane Iacofo", "bid": 29, "yaxis": 21, "xaxis": 2 }, { "cid": 159, "content": "Jereme Chelam", "bid": 29, "yaxis": 32, "xaxis": 94 }, { "cid": 179, "content": "Tedra Govern", "bid": 29, "yaxis"..