묻고 답해요
161만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
주문할 때 상품 여러개 선택하는 기능 추가
안녕하세요, 이 프로그램을 좀 더 발전시켜보고 싶은데요 주문할 때 상품을 여러개 선택하도록 만들고싶은데, 이렇게 하려면 상품과 주문 수량을 골랐을 때 다시 화면에 추가로 선택 칸이 만들어져야 할 것 같습니다. 이 기능을 혹시 스프링과 타임리프 만으로 구현할 수 있나요, 아니면 자바스크립트를 공부해서 만들어야 할까요? 대략적인 가이드라도 조언 부탁드립니다. 감사합니다.
-
해결됨스프링 핵심 원리 - 기본편
빈 관련 에러
안녕하세요, org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'hello.core.order.OrderServiceImpl' available 에러가 발생하였습니다. ac.get을 어떻게 수정해야할까요 ㅜ
-
미해결스프링 MVC 2편 - 백엔드 웹 개발 활용 기술
httpsession.setAttribute()가 response에 JSESSIONID 값을 전달해주는 역할도 하나요?
// 로그인 성공 처리 //세션이 있으면 있는 세션 반환, 없으면 신규 세션 생성해줌 HttpSession session = request.getSession(); //서버의 세션에 로그인 회원 정보 보관 session.setAttribute(SessionConst.LOGIN_MEMBER, loginMember); return "redirect:/"; 로그인을 하는 코드인데 session.setAttribute()가 httpsession에 해당 키와 value를 저장하고나서 response header에 전달되는 JSESSIONID의 값을 랜덤으로 생성해서 보내주는건가요? 아니면 누가 JSESSIONID를 response header에 보내주는 건가요?
-
미해결스프링 MVC 2편 - 백엔드 웹 개발 활용 기술
[자문자답] helloMessage() 에러 참고하세요
expected 가 "hello"일 경우 자신의 기본 OS가 en일 가능성이 있습니다. System.out.println(Locale.getDefault()); 를 통해 기본 Locale 설정을 확인해볼 수 있습니다. 강의 코드를 그대로 따라 치려면, 테스트 메소드 내부에 Locale.setDefault(Locale.KOREA); 를 추가하면 기본 Locale을 한시적으로 ko_KR로 변경 가능합니다.
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
stream
안녕하세요! 6:40초 쯤에 보면, 이 코딩이 이해가 잘 가지않아 질문을 드리게 되었습니다. 이 부분이 stream + 람다식 문법을 사용한게 맞을까요? 아래처러머 제가 이해한 게 맞는지 궁금합니다 ㅠㅠ.. store라는 참수변수의 value(값)을 stream을 통해 읽고, filter()를통해 데이터를 걸러내고 마지막 최종연산으로 findAny()로 name을 찾아낸다.. 가 맞을까요?
-
해결됨스프링 핵심 원리 - 기본편
Assertion 질문
Assertion 이전에 assertj로 사용을 한 이후에 바로 주피터 것을 사용하려고 했는데 저는 주피터꺼 임폴트해서 엔터 눌렀음에도 불구하고 교수님처럼 org.junit.jupiter.api.Assertions로 변경이 안됩니다.. 왜 그런지 알 수 있을까요!? 아래와 같이 뜹니다..
-
해결됨스프링부트 시큐리티 & JWT 강의
Google Cloud 에 OAuth 테스트 프로젝트를 만들게 되면, 비용이 발생하는지 궁금합니다.
안녕하세요 OAuth Google 강의를 진행하려고 하는데, 문의 사항이 있습니다. Google Cloud 에 테스트 프로젝트를 만들게 되면, 비용이 발생하는지 궁금합니다. 제가 Google Cloud 사용 경험이 없어서 문의를 드립니다.
-
미해결스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술
Redirect 질문
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]안녕하세요, redirect 부분에서 질문이 있어 문의 남깁니다. ControllerV1~V4 까지는 view 이름(String)을 반환하여 그에 맞는 view 를 찾아 모델을 넣는것으로 이해했습니다. 하지만 이번강의와 저번강의에서 나온 redirect 가 이해가 되지 않습니다. redirect 가 붙은경우, view 를 찾는것이 아닌 url 로 가게 되는것인가요?
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
질문있습니다!!
강의를 보던 중에 연관 관계 메소드에 관련되어서 질문이 있습니다. Category 클래스에서 보면 엔티티 안에서 멤버 변수들끼리 양방향 관계를 맺는 parent랑 child가 있는데 아래 코드가 잘 이해가 안됩니다. this.child는 멤버 변수 child를 의미하는데 child 리스트 안에 파라미터인 child를 넣는다는 뜻인건가요? 그리고 child.setParent에는 왜 this가 들어가나요..? this는 객체 자신인 Category라고 알고 있는데 제가 잘못 안건가요? public void addChildCategory(Category child){ this.child.add(child); child.setParent(this);}
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
스프링 데이터 JPA 메서드 두 번 호출 이슈
리파지토리에 스프링 데이터 JPA를 적용하고 AOP를 실습해본 결과 리파지토리 메서드들이 두 번 호출되고 있습니다. 이유를 찾고자 구글링도 해봤는데 명확한 답을 못찾았네요.. 원인과 이유를 찾을 수 있는 디버깅 방법을 알 수 있을까요? Service Join 호출 로그
-
해결됨스프링 핵심 원리 - 기본편
에러,AssertThat
AssertThat 부분 에러가 왜 나는 것일까요.. ㅠ 혹시몰라 import 때문인 줄 알고 import static org,assertj.core.api.Assertions.*; 를 추가하였으나 자동 주석처리 됩니다,,
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
JDBC 강의 질문입니다.
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]안녕하세요. 인텔리제이나 h2 콘솔에서 에러가 뜨지는 않습니다. 그런데 localhost8080에 접속하여 수강 목록에 들어갔을때 새로운 창으로 넘어가지 않고, 가입창에서 입력을 했을때도 데이터베이스에 저장이 되거나 홈화면으로 리다이렉트되는 등의 조치가 시행되지 않습니다.. 무엇이 문제인지 궁금합니다. 감사합니다. https://drive.google.com/file/d/1j3y1a2OuGRsjAHbAITL-iFoAPqClJgbr/view?usp=sharing
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
연관관계 편의메서드를 적용하지 않을때 문제점이 어떤것이 있나요?
스프링 데이터 jpa를 사용하여 여러 연관관계를 가진 엔티티를 만들었는데 이 강의에서처럼 연관관계 편의메서드에서 하신 것처럼 연관관계가 설정된 엔티티에 따로 설정(member.getOrders().add(this) 같은) 을 따로 해주지 않았는데 문제가 없었습니다. 특별히 어떤 이유에서 연관관계 설정 메서드를 정의하신건가요?
-
미해결스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술
쓰레드를 사용한다는 게 request response 때마다 썼다 풀렸다 하는 건가요?
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]여기에 질문 내용을 남겨주세요. 이제 막 네트워크 배우고 넘어왔는데 HTTP 연결은 계속해서 이어지는 게 아니고 rquest를 받은 뒤 response를 보내면 연결을 끊고 request를 다시 받으면 다시 연결하고 이런 걸로 알고 있는데요 쓰레드도 계속 이런 식으로 동작하는 건가요??
-
미해결스프링 DB 1편 - 데이터 접근 핵심 원리
@Autowired
궁금한게 그전에 핵심원리강의에서는 @Componentpublic class MemberServiceImpl implements MemberService { private final MemberRepository memberRepository; @Autowired public MemberServiceImpl(MemberRepository memberRepository) { this.memberRepository = memberRepository; }} 이런식으로 @Autowired로 주입을 받았는데 여기서는 왜 안쓴건가요?
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
Entity 메소드 파라미터로 DTO를 받는 것, 괜찮을까요?
1. 강의 내용과 관련된 질문인가요? 아니오2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? 예3. 질문 잘하기 메뉴얼을 읽어보셨나요? 예[질문 내용]안녕하세요? JPA 수업 수강 후, 실제 업무에 적용하는 와중에 궁금한 점이 있어서 질문 남깁니다. DB Update를 위한 Entity Method의 파라미터로 DTO를 받는 것이 프로그램 구동상에는 전혀 문제는 없는데요. Domain driven design을 구현하는데에 있어서 엔티티 메소드의 파라미터로 DTO를 집어넣는게 바람직한 설계(?) 인지 문의 드립니다. 질문의 보다 빠른 이해를 위해 샘플 코드 및 시나리오를 아래와 같이 남깁니다. - 상황 : 회원정보수정 API의 input으로 MemberDTO를 받음 - MemberDTO 내에 ContactDTO, List<AddressDTO>를 가진 구조 (Nested) class MemberDTO { ... private ContactDTO contactDTO; private List<AddressDTO> addressDTO; ... } - Service 레벨에서 memberRepository.findById() 통하여 Member Entity를 불러옴. - Member Entity와 Contact Entity은 1:1조인, Address Entity와는 1:N 조인 - Contact 및 Address 업데이트를 위해 Entity레벨에 다음의 메소드를 구현해두었으며, member.getContact().updateContact(contactDTO)로 해당 메소드를 호출 @Entity class Contact(또는 Address) { ... public void updateContact (ContactDTO contactDTO) { ... this.phoneNumber = contactDTO.getPhoneNumber(); ... ... } } 감사합니다.
-
미해결스프링 DB 2편 - 데이터 접근 활용 기술
spring.profile.active=test 에러
안녕하세요. 강의에서 말씀해주신 /src/test/resources/application.properties 파일에서 테스트 profile설정을 완료 했는데요. ItemRepositoryTest 실행 시 테스트 profile 설정을 읽어오지 못하는 것 같아서 질문 드려요. 실행해보면 아래 메세지가 뜨고, 스프링이 띄워지는데 profile 정보가 "local"로 잡히네요. 원인을 검색해봤는데 해결 가능한 답변을 찾지 못해서 질문드립니다. ㅠ 18:03:27.880 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate] 18:03:27.918 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)] 18:03:28.051 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [hello.itemservice.domain.ItemRepositoryTest] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper] 18:03:28.088 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [hello.itemservice.domain.ItemRepositoryTest], using SpringBootContextLoader 18:03:28.103 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [hello.itemservice.domain.ItemRepositoryTest]: class path resource [hello/itemservice/domain/ItemRepositoryTest-context.xml] does not exist 18:03:28.105 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [hello.itemservice.domain.ItemRepositoryTest]: class path resource [hello/itemservice/domain/ItemRepositoryTestContext.groovy] does not exist 18:03:28.105 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [hello.itemservice.domain.ItemRepositoryTest]: no resource found for suffixes {-context.xml, Context.groovy}. 18:03:28.107 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [hello.itemservice.domain.ItemRepositoryTest]: ItemRepositoryTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration. 18:03:28.176 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [hello.itemservice.domain.ItemRepositoryTest] 18:03:28.261 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [C:\workspaces\spring-db-2\itemservice-db\bin\main\hello\itemservice\ItemServiceApplication.class] 18:03:28.264 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration hello.itemservice.ItemServiceApplication for test class hello.itemservice.domain.ItemRepositoryTest 18:03:28.407 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [hello.itemservice.domain.ItemRepositoryTest]: using defaults. 18:03:28.408 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener] 18:03:28.432 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@1f6c9cd8, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@5b619d14, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@66746f57, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@447a020, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@7f36662c, org.springframework.test.context.support.DirtiesContextTestExecutionListener@28e8dde3, org.springframework.test.context.transaction.TransactionalTestExecutionListener@6d23017e, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@54dcfa5a, org.springframework.test.context.event.EventPublishingTestExecutionListener@1817f1eb, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@767e20cf, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@3a3e78f, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@301ec38b, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@17a1e4ca, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@10ded6a9, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@c5dc4a2] 18:03:28.437 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@35d08e6c testClass = ItemRepositoryTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@53d102a2 testClass = ItemRepositoryTest, locations = '{}', classes = '{class hello.itemservice.ItemServiceApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@4b8d604b, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@3932c79a, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@821330f, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@210ab13f, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@6a4f1a55, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@4c40b76e], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null]. INFO 15312 --- [ main] h.itemservice.domain.ItemRepositoryTest : The following 1 profile is active: "local"
-
미해결스프링 핵심 원리 - 고급편
test 메서드 snake case
영한님 안녕하세요. 테스트 케이스 작성하실 때, 메서드 이름을 camel 케이스가 아니라 snake case로 작성하시던데, db 강의 때도 그렇게 하셔서 궁금했는데 뭔가 이유가 있으신 건가요?
-
미해결스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술
@ModelAttribute 생성자
1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]여기에 질문 내용을 남겨주세요. ModelAttribute 사용시, 객체를 생성한후 프로퍼티바운딩을 해준다고 배웠는데, Item 클래스에는 기본생성자가 없어서 객체를 어떻게 만드나 궁금해서 soutm을 찍어보니 Item(String name, Integer price, Integer quntity) 생성자를 호출해 주더라고요, 그리고 Item 클래스에 Item() 생성자를 만들어주면 ModelAttribute이용시에 Item()생성자를 호출하는것을 확인했습니다. 여기에서 질문하겠습니다. ModelAttribute 사용시 객체를 생성할때, 여러생성자가 있다면, 어떤 생성자가 호출되는지 메커니즘이 있나요?
-
미해결실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
N+1 문제를 맞게 이해한 것인지 잘 모르겠습니다.
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]여기에 질문 내용을 남겨주세요. 이번 강의를 통해 공부하면서 N+1문제를 아래와 같이 이해하였습니다. ex) 모든 주문 내역을 가져오는 경우 -> 실제로 나가는 쿼리는 select * from orders 쿼리 한방이지만, 1) 이때 지연로딩인 경우 , 조회한 order에 대해 member나 delivery를 필요로 하는 경우에 각 order별로 member나 delivery 조회 쿼리가 N번씩 나가게 되고 2) 즉시 로딩인 경우, select * from orders 라는 모든 주문 조회 쿼리 한방이 나간 후, 곧바로 조회한 order들과 연과된 member와 delivery 조회 쿼리가 이어서 나가게 된다. (단 이떄 예측할 수 없는 쿼리가 나갈 수 있음.) 즉 정리하면 즉시로딩과 지연로딩 모두 N+1 문제가 발생할 수 있지만, 즉시로딩은 예측할 수 없는 쿼리가 나갈 수도 있어 최적화 시키기 어려운 반면, 지연 로딩은 페치 조인을 사용하여 order를 조회하면서 동일 쿼리 상에서 member나 delivery도 함께 가져오게 하는방법으로 최적화 시킬 수 있으니, 지연로딩을 사용하는것이 옳다. 라고 이해하였는데, 맞게 이해한 것인지 잘 모르겠습니다. 감사합니다.