inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

172만명의 커뮤니티!! 함께 토론해봐요.

MemberRepositoryTest를 junit5용으로 고쳤는데 오류가발생합니다 + junit4를 사용해야만 할까요?

미해결

실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발

https://drive.google.com/file/d/1PBHzDQJ0Odvh2KWMa_BTOu3PZqHrMJkj/view?usp=drive_link MemberRepositoryTest를 실행하면 이렇게 됩니다. junit5로 하고 있는데 이런식으로 오류가 발생합니다. JPA와 DB 설정, 동작확인 13분경까지 들었습니다. JpashopApplication를 실행해도 오류가 발생하기 시작했습니다.

  • java
  • spring
  • 웹앱
  • spring-boot
  • jpa
peter 댓글 2 좋아요 0 조회수 109

캐시 구현에서 Redis - MongoDB 스코프

미해결

배달앱은 어떻게 내 주변의 맛집을 찾을까?

제가 이해한 구조는 아래와 같습니다. Request -> API -> Service -> Entity Redis에서 캐시 조회 실패하면 redis에서 몽고 db collection 관련 함수를 직접 조회 하는 게 아니라 서비스로 돌아가서 서비스단에서 몽고 db collection 관련 함수를 호출하는게 맞지 않나요? 아니면 주신 코드 처럼 Entity 단에서는 서로를 호출하면서 작동하는게 맞나요?

  • python
  • mongodb
  • FastAPI
파사 댓글 2 좋아요 0 조회수 168

키생성 방식에 따른 성능

미해결

실습으로 배우는 선착순 이벤트 시스템

안녕하세요. 문제점 해결하기 강의에서 실습을 잘 진행했습니다. 실험을 하며 결과를 관측하던 중, @NoArgsConstructor(access = AccessLevel.PROTECTED) @RequiredArgsConstructor @Entity public class Coupon { @Id @GeneratedValue private Long id; } 위와 같이 @GeneratedValue를 적용하면 로그패턴도 달라지고 성능이 급격하게 나빠지더라고요 @Id @GeneratedValue(strategy = GenerationType.IDENTITY) 로 지정하면 실습이 잘 진행됩니다. 왜 이런차이가 발생하는지 알 수 있을까요? strategy를 선택하지 않으면 AUTO이며 이는 mysql에서 IDENTITY를 선택한 것과 같게 나와야하는데 예상과 달라 질문드려봅니다.

  • java
  • docker
  • spring-boot
  • kafka
  • redis
창신동 장첸 댓글 2 좋아요 0 조회수 193

값 타입 컬렉션 대안

미해결

자바 ORM 표준 JPA 프로그래밍 - 기본편

아래와 같이 엔티티를 만들고, 여기에서 값 타입을 사용하는 것은 임베디드 타입을 사용하는 것과 어떤 차이가 있나요? @Embedded라는 애노테이션을 붙이지 않아서 질문드립니다. 똑같이 엔티티에서 Address 객체를 필드로 갖는데 무슨 차이인가 해서요.

  • java
  • jpa
최재량 댓글 1 좋아요 0 조회수 140

선생님 질문 있습니다.

미해결

파이썬/장고 웹서비스 개발 완벽 가이드 with 리액트 (장고 4.2 기준)

1) request.META["HTTP_USER_AGENT"] 실습 5번 내내 NameError로 표기 되지 않습니다. 구글링해도 정확히 어떤 이유인지 잘모르겠습니다. 2) 아래 pwsh 느낌표가 왜 나오는지 궁금합니다.

  • react
  • python
  • django
  • web-api
  • htmx
lkh5040 댓글 1 좋아요 0 조회수 96

안녕하세요 선생님,

미해결

파이썬/장고로 웹채팅 서비스 만들기 (Feat. Channels) - 기본편

#consumers.py from asgiref.sync import async_to_sync from channels.generic.websocket import JsonWebsocketConsumer from chat.models import Room # 모든 유저가 고정된 채널 레이어 그룹을 가질것. class ChatConsumer(JsonWebsocketConsumer): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) SQUARE_GROUP_NAME = "square" self.group_name = [SQUARE_GROUP_NAME] self.room = None def connect(self): user = self.scope['user'] if not user.is_authenticated: self.close() else: room_name = self.scope['url_route']['kwargs']['room_pk'] try: self.room = Room.objects.get(pk=room_name) except Room.DoesNotExist: #지정 룸 pk에 룸 인스턴스가 없을 경우 웹소켓 연결요청 수락. pass else: self.group_name = self.SQUARE_GROUP_NAME is_new_join = self.room.user_join(self.channel_name, user) if is_new_join: async_to_sync(self.channel_layer.group_send)( self.group_name, { "type": "chat.user.join", "username": user.username, } ) async_to_sync(self.channel_layer.group_add)( self.group_name, self.channel_name ) self.accept() def disconnect(self, code): if self.group_name: async_to_sync(self.channel_layer.group_discard)( self.group_name, self.channel_name ) user = self.scope['user'] if self.room is not None: is_last_leave = self.room.user_leave(self.channel_name, user) if is_last_leave: async_to_sync(self.channel_layer.group_send)( self.group_name, { "type": "chat.user.leave", "username": user.username, } ) def chat_user_join(self, message_dict): self.send_json({ "type": "chat.user.join", "username": message_dict["username"], }) def chat_user_leave(self, message_dict): self.send_json({ "type": "chat.user.leave", "username": message_dict["username"], }) def chat_message(self, message_dict): self.send_json({ "type": "chat.message", "message": message_dict["message"], "sender": message_dict["sender"], }) def receive_json(self, content, **kwargs): user = self.scope["user"] _type = content["type"] if _type == "chat.message": message = content["message"] sender = user.username async_to_sync(self.channel_layer.group_send)( self.SQUARE_GROUP_NAME, { "type": "chat.message", "message": message, "sender": sender, } ) else: print(f"Invalid message type : ${_type}") room_name = self.scope['url_route']['kwargs']['room_pk'] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^ KeyError: 'room_pk' 이런 에러가 나서, urls.py, views.py, index.html도 맞춰줘 봤지만, 잘 해결이 되질 않습니다. 어떤식으로 이 에러를 처리해야할까요. 오늘도 좋은 하루 되시길 바랍니다. 감사합니다.

  • python
  • django
  • django-channels
sunnnwo 댓글 1 좋아요 0 조회수 116

상세페이지로 이동하는 url을 받아서 이동할때, url유형이 달라요

미해결

[신규 개정판] 이것이 진짜 크롤링이다 - 실전편 (인공지능 수익화)

상세페이지 href속성을 찾아 기존페이지 url?상세페이지 url을 적용하여 실습을 성공해 오다가 난관에 부딪혔습니다. html속성값을 보니 아래와 같이 되어 있고 url에 붙이거나 해도 페이지가 로드 되지 않아 어려움을 겪고 있습니다. <a href="Javascript:view_content('869');">처리 일정 문의 드립니다.</a> 위와같은 href가 나타날때는 어떻게 상세페이지로 이동해야 하는지 궁금하고 이럴때 혹시 우회할 수 있는 대안이 있다면 알고 싶어요

  • python
  • 웹-크롤링
민소리 댓글 1 좋아요 0 조회수 123

MemberRepositoryTest junit5로 고친후 오류발생 + junit4를 사용해야만 할까요?

미해결

실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발

junt4로 gradle에서 설정하려고 하면 오류가 발생해서 juit5로 하는 중입니다. MemberRepositoryTest를 junit5버전으로 고쳐서 아래의 코드로 실행했는데 오류가 나고 있습니다 import jpabook.jpashop.Member; import jpabook.jpashop.MemberRepository; //import jpabook.jpashop.domain.Member; //import jpabook.jpashop.repository.MemberRepository; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.Transactional; @ExtendWith(SpringExtension.class) // JUnit 5 방식 @SpringBootTest public class MemberRepositoryTest { @Autowired MemberRepository memberRepository; @Test @Transactional @Rollback(false) public void testMember() { Member member = new Member(); member.setUsername("memberA"); Long savedId = memberRepository.save (member); Member findMember = memberRepository.find(savedId); Assertions.assertThat(findMember.getId()).isEqualTo(member.getId()); Assertions.assertThat(findMember.getUsername()).isEqualTo(member.getUsername()); Assertions.assertThat(findMember).isEqualTo(member); // JPA 엔티티 동일성 보장 } } 밑에는 오류입니다. Unable to find a @SpringBootConfiguration by searching packages upwards from the test. You can use @ContextConfiguration, @SpringBootTest(classes=...) or other Spring Test supported mechanisms to explicitly declare the configuration classes to load. Classes annotated with @TestConfiguration are not considered. java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration by searching packages upwards from the test. You can use @ContextConfiguration, @SpringBootTest(classes=...) or other Spring Test supported mechanisms to explicitly declare the configuration classes to load. Classes annotated with @TestConfiguration are not considered. at org.springframework.util.Assert.state(Assert.java:79) 1. @SpringBootTest(classes=...) 로 명시적으로 설정 클래스 지정 2. @SpringBootApplication 이 있는 클래스의 위치 확인 3. @ContextConfiguration 을 사용해서 명시적으로 설정 클래스 지정 이세가지를 시도해도 안되고 있습니다. 아니면 juni4룰 사용해야만 할까요? build.gradle에 JUnit4 추가 testImplementation("org.junit.vintage:junit-vintage-engine") { exclude group: "org.hamcrest", module: "hamcrest-core" } 를 하면 Build file 'C:\Users\Peter\Desktop\study\jpashop\build.gradle' line: 45 A problem occurred evaluating root project 'jpashop'. > Could not find method testImplementation() for arguments [org.junit.vintage:junit-vintage-engine, build_55eer8btj8rd1l6xp0yqapa0y$_run_closure6@6e20627f] on root project 'jpashop' of type org.gradle.api.Project. 라고 나옵니다.

  • java
  • spring
  • 웹앱
  • spring-boot
  • jpa
댓글 3 좋아요 0 조회수 476

SbbApplicationTests 런오류 tetJpa부분?

미해결

백엔드 개발을 위한 필수 강의 - 스프링 부트3

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled. 2025-02-13T00:15:43.156+09:00 ERROR 7780 --- [ main] o.s.boot.SpringApplication : Application run failed Error creating bean with name 'entityManagerFactory' 이런 오류가 뜹니다 쿼리가 안 만들어져요 이오류 때문에 ㅜ

  • java
  • aws
  • spring-boot
손진주 댓글 1 좋아요 0 조회수 98

SbbApplicationTests에서 JUnit Test런을 하면 x표시하며 오류가나요!!!

미해결

백엔드 개발을 위한 필수 강의 - 스프링 부트3

package com.mysite.sbb; import static org.junit.jupiter.api.Assertions. assertEquals ; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class SbbApplicationTests { @Autowired private QuestionRepository questionRepository ; @Test void testJpa() { Question q = this . questionRepository .findBySubjectAndContent( "sbb가 무엇인가요?" , "sbb에 대해서 알고 싶습니다." ); assertEquals (1, q .getId()); } }

  • java
  • aws
  • spring-boot
손진주 댓글 1 좋아요 0 조회수 135

양방향 매핑에서 보여주는 테이블 연관관계의 관계선표기가 제대로 되어있는건가요 ?

미해결

자바 ORM 표준 JPA 프로그래밍 - 기본편

[질문 템플릿] 1. 강의 내용과 관련된 질문인가요? 예 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? 예 3. 질문 잘하기 메뉴얼을 읽어보셨나요?  [질문 내용] PPT 양방향 매핑에서 테이블연관관계를 나타낼때 TEAM의 PK가 MEMBER의 FK 로 존재한다면 실선이 아닌 점선으로 표현되어야 하는 것 아닌가요 ? MEMBER의 경우 TEAM_ID가 PK가 아니니까 null을 허용할 수 있으니 팀이 없는 경우가 존재할 테니까 멤버가 팀을 가지고 있는 것은 선택적인 관계로 점선으로 표현해야하는 것이 아닌가 싶습니다

  • java
  • jpa
a787574 댓글 1 좋아요 0 조회수 105

쿼리문이 console에서 형성이 안되고 아래와 같은 코드오류걸려요

미해결

백엔드 개발을 위한 필수 강의 - 스프링 부트3

package com.mysite.sbb; import static org.junit.jupiter.api.Assertions. assertEquals ; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class SbbApplicationTests { @Autowired private QuestionRepository questionRepository ; @Test void testJpa() { Question q = this . questionRepository .findBySubjectAndContent( "sbb가 무엇인가요?" , "sbb에 대해서 알고 싶습니다." ); assertEquals (1, q .getId()); } }

  • java
  • aws
  • spring-boot
손진주 댓글 1 좋아요 0 조회수 125

SbbApplicaitonTest JUnit 테스트 런을 하면 아래와 같은 오류가 Console에 뜹니다

미해결

백엔드 개발을 위한 필수 강의 - 스프링 부트3

19:49:22.386 [main] INFO org.springframework.test.context.support .AnnotationConfigContextLoaderUtils -- Could not detect default configuration classes for test class [com.mysite.sbb.SbbApplicationTests]: SbbApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration. console에 위와 같은 문구가 나오고 아래로 실행 문구가 뜨지 않습니다.

  • java
  • aws
  • spring-boot
댓글 1 좋아요 0 조회수 132

[리포지터리] SbbApplicationTests에서부터 오류

미해결

백엔드 개발을 위한 필수 강의 - 스프링 부트3

package com.mysite.sbb; import java.time.LocalDateTime; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class SbbApplicationTests { @Autowired private QuestionRepository questionRepository; @Test void testJpa() { Question q1 = new Question(); q1.setSubject("sbb가 무엇인가요?"); q1.setContent("sbb에 대해서 알고 싶습니다."); q1.setCreateDate( LocalDateTime.now ()); this.questionRepository.save (q1); // 첫번째 질문 저장 Question q2 = new Question(); q2.setSubject("스프링부트 모델 질문입니다."); q2.setContent("id는 자동으로 생성되나요?"); q2.setCreateDate( LocalDateTime.now ()); this.questionRepository.save (q2); // 두번째 질문 저장 } } 런타임을 시작하면 위에 첨부된 파일에 빨간색 x표시로 오류가 뜹니다. Bootdashboard에 중지버튼이 비활성화되어있어요

  • java
  • aws
  • spring-boot
손진주 댓글 1 좋아요 0 조회수 120

심사위원 문제 시간복잡도 질문

해결됨

자바 코딩테스트 - it 대기업 유제

안녕하세요. sorting 파트의 문제 4번 심사위원 문제의 시간복잡도 질문입니다. 정답 코드에서 score를 순회하며 getAve 함수를 호출하면서 이중 for문이 실행됩니다. score의 최대 길이가 30만이고, k가 최대 10만이므로 시간 복잡도는 O(nk)입니다. 최악의 경우 30만 × 10만 = 300억 번 연산이 발생하는데, 이는 1~2초의 제한 시간 내에 절대 수행될 수 없으므로 시간 초과가 발생하는 코드가 맞나요? 또한 제 풀이도 평가 부탁드립니다. 누적합 배열을 사용해서 풀어봤습니다. 이러면 시간복잡도가 O(nlogn)이 나와서, 최악의 경우라도 O(90만)이라고 계산했는데, 맞을까요? import java.util.*; class Solution { public int solution(int[] score, int k){ int answer = 0, n = score.length; Arrays.sort(score); //pre: 누적합 배열 int[] pre = new int[n]; pre[0] = score[0]; //누적합 구하기 for(int i = 1; i < n; i++){ pre[i] = pre[i-1] + score[i]; } //score 순회하면서, 조건 만족하면 누적합 배열로 평균 구하기 for(int i = 0; i <= n - k; i++){ if(score[i + k - 1] - score[i] <= 10){ int tmp; if(i == 0){ tmp = pre[i + k - 1]; }else{ tmp = pre[i + k - 1] - pre[i - 1]; } tmp /= k; //평균 answer = tmp; break; } } return answer; } public static void main(String[] args){ Solution T = new Solution(); System.out.println(T.solution(new int[]{99, 97, 80, 91, 85, 95, 92}, 3)); System.out.println(T.solution(new int[]{92, 90, 77, 91, 70, 83, 89, 76, 95, 92}, 4)); System.out.println(T.solution(new int[]{77, 88, 78, 80, 78, 99, 98, 92, 93, 89}, 5)); System.out.println(T.solution(new int[]{88, 99, 91, 89, 90, 72, 75, 94, 95, 100}, 5)); } }

  • java
  • 코딩-테스트
윤휘영 댓글 1 좋아요 0 조회수 145

%0이 짝수라는뜻인가요?

미해결

문과생도, 비전공자도, 누구나 배울 수 있는 파이썬(Python)!

50%2를 하면 25인데 25일경우에는 0이 아닌데 이해가 잘 안되어서요 그냥 %2=0이면 짝수라는 통용되는 개념인가요?

  • python
escho94 댓글 1 좋아요 0 조회수 153

continue에 관해서 질문드립니다

미해결

문과생도, 비전공자도, 누구나 배울 수 있는 파이썬(Python)!

for i in range(10): print(i) if i < 5: continue elif i == 7: break 여기서 출력값이 01234567이 나왔는데 567이 나오는건 이해하겠는데 0부터 4는 if구문의 continue 때문에 건너뛰어야하는것 아닌가요..? 왜 이렇게 출력이 되는지 궁금해요

  • python
댓글 1 좋아요 0 조회수 124

지역 클래스 캐스팅 질문

미해결

김영한의 실전 자바 - 중급 1편

1. 강의 내용과 관련된 질문인가요? 예 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? 예 3. 질문 잘하기 메뉴얼을 읽어보셨나요? 예 안녕하세요 지역 클래스 부분을 수강하다 궁금한 점이 있어 여쭤봅니다. 지역 클래스 파트의 코드를 확인하면 Printer process라는 메서드 안 return printer; 바로 위에 LocalPrinter printer = new LocalPrinter(); 이라는 코드가 강의에서 나옵니다. 그런데 제공해주신 강의 자료에는 해당 부분이 Printer printer = new LocalPrinter();로 형이 다르던데 혹시 이것은 오타일까요 ? 익명 클래스를 수강하다 다른 점이 있어 되돌아와서 찾아보는 중이었습니다 ! 좋은 강의 제공해주셔서 감사합니다 !!

  • java
  • 객체지향
wonderwall09in 댓글 2 좋아요 0 조회수 120

강의와 살짝 무관하지만.. MQ에 대한 질문이 있습니다!

해결됨

RabbitMQ를 이용한 비동기 아키텍처 한방에 해결하기

RabbitMQ도 충분히 강력한 기능을 제공하는 것으로 보입니다. 근데 이제 한번 소비한 메시지는 소비하면서 어딘가에 또 저장하지 않는 이상 재시도가 어려운것으로 알고있습니다. 현업에서 RabbitMQ를 도입하시고 사용하시면서 Kafka의 어떤 토픽의 0번 오프셋부터 읽기(earliest)같은 요구사항이 있었던 적은 없으셨는지 궁금합니다!

  • java
  • spring-boot
  • jpa
  • msa
  • websocket
  • rabbitmq
보키 댓글 1 좋아요 0 조회수 228

조회수 어뷰징 방지 부분에서 질문이 있습니다.

해결됨

스프링부트로 직접 만들면서 배우는 대규모 시스템 설계 - 게시판

안녕하세요. "조회수 어뷰징 방지 정책 구현" 강의의 ViewApiTest.viewTesst를 실행한 다음 redis가 동작하는 docker에 접속해 redis-cli를 실행하고 "keys *" 명령어를 실행하면, distributed lock이나 조회수에 관련된 key를 찾을 수 없습니다. database 0~15를 돌며 "keys *"를 실행 했을 때 (empty array)를 응답 받고 있습니다. 어떤 방법으로 결과를 확인할 수 있을까요?

  • java
  • mysql
  • spring-boot
  • kafka
  • redis
오승호 댓글 2 좋아요 0 조회수 240

인기 태그

인프런 TOP Writers

주간 인기글