묻고 답해요
161만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결스프링 DB 2편 - 데이터 접근 활용 기술
여러방식의 데이터접근기술을 같이 사용하는 경우
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)예2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 예3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)예[질문 내용]기본적으로 JPA 를 통해 DB 접근을 하지만 몇몇 쿼리들을 JdbcTemplate 를 활용해 DB접근을 한다고 가정한다면 일반적으로 어떤식으로 구조를 만들어내는지 궁금합니다. ItemRepository 인터페이스를 구현한 JpaTemplate 를 만들어 ItemRepository 를 주입받을 때 그 구현체로 JpaTemplate 가 주입되게 하되, JdbcTemplate 는 ItemRepository 구현체가 아닌 별도의 컴포넌트로 만들어 필요한 부분에서는 별도로 주입받아 사용하게 되는걸까요?
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
item엔티티에 질문있습ㄴ디ㅏ.
Item엔티티도 OrderItem과 (아이템기준)onetomany인데 왜 private List<OrderItem> orderItems = new ArrayList<>(); item에 이런문구를안넣어주나요?
-
미해결스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술
get set 오류
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]ItemRepository 파일 내 setId()와 getId() 부분에서 오류가 발생하고 있습니다. test 도 동일하게 오류 발생하고 있습니다. 어떤 점이 문제인지 확인 부탁 드립니다.https://drive.google.com/file/d/1iGTvLwfkrcbkCev-IjHXoOyXlCuzA8y-/view?usp=sharing
-
해결됨스프링 DB 1편 - 데이터 접근 핵심 원리
레포지토리에서 동기화를 사용하지 않은 이유가 따로 있으실까요?
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]동기화가 필요하지 않은 서비스 로직이라 동기화를 일부러 적용 안하신건지 아니면 그냥 단순하게 예제를 만들기 위해 생략한 것인지 궁금합니다!
-
미해결스프링 핵심 원리 - 기본편
clientBean 은 프로토타입 빈의 참조값을 보관하는거 있잖아요
ApplicationContext ac = new AnnotationConfigApplicationContext(ClientBean.class, PrototypeBean.class); ClientBean clientBean = ac.getBean(ClientBean.class); clientBean 이 prototypeBean 을 바로 참조하는게 아니라clientBean 에 생성된 prototypeBean 참조하면 그 안에생성 시점에 주입 받은 참조 값을 참조하는 건가요?맞나요? 헷갈려요 ㅠ
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
서비스 코드 에러
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]여기에 질문 내용을 남겨주세요. > Run with --info or --debug option to get more log output.> Run with --scan to get full insights.> Get more help at https://help.gradle.org.Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.For more on this, please refer to https://docs.gradle.org/8.7/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.BUILD FAILED in 6s3 actionable tasks: 1 executed, 2 up-to-date 이런 오류가 뜹니다.코드보다 설정 문제인 것 같은데 혹시 뭐가 문제일까요?
-
미해결토비의 스프링 부트 - 이해와 원리
다음 강의 오픈 일정 알 수 있을까요?
늦으면 4월이라고 하신 답변을 본 것 같은데 기다리고 있습니다!!
-
미해결스프링 MVC 2편 - 백엔드 웹 개발 활용 기술
@GetMapping("variable")이라고 작성해도 되는 이유
실습시 BasicController에서 @GetMapping("/variable")@GetMapping("variable")둘 다 http://localhost:8080/basic/variable입력시 컨트롤러 호출이 되는것을 확인할 수 있었습니다. 왜 후자의 variable도 가능한건가요?
-
미해결Practical Testing: 실용적인 테스트 가이드
OrderRepositoryTest에서 단위테스트가 가능한가요?
@SpringBootTest class OrderRepositoryTest { @Autowired private OrderRepository orderRepository; @Autowired private ProductRepository productRepository; @DisplayName("해당 날짜의 모든 결제 내역을 조회한다.") @Test void findAllByDate() { // given LocalDateTime time1 = LocalDateTime.of(2024, 5, 11, 10, 0); LocalDateTime time2 = LocalDateTime.of(2024, 5, 10, 10, 0); Product product1 = createProduct("001"); Product product2 = createProduct("002"); Product product3 = createProduct("003"); Product product4 = createProduct("004"); productRepository.saveAll(List.of(product1, product2, product3, product4)); Order order1 = Order.builder() .products(List.of(product1, product2)) .now(time1) .build(); Order order2 = Order.builder() .products(List.of(product3, product4)) .now(time2) .build(); orderRepository.saveAll(List.of(order1, order2)); // when LocalDate findDate = LocalDate.of(2024, 5, 11); List<Order> findOrders = orderRepository.findAllByDate( findDate.atStartOfDay(), findDate.plusDays(1).atStartOfDay(), OrderStatus.INIT ); // then Assertions.assertThat(findOrders).hasSize(1); } private static Product createProduct(String number){ return Product.builder() .productNumber(number) .productType(ProductType.HAND_MADE) .sellingType(ProductSellingType.SELLING) .name("test") .price(1000) .build(); } } OrderRepositoryTest에서 매서드 테스트를 할 때, Order와 Product는 1대다 다대1로 연관관계 매핑되어 있는 상태인데, 그러면 위와 같이 작성할 경우, productRepository와 관련된 코드가 들어가니, 단위테스트가 깨지는거 아닌가요? 이럴때 어떻게 해야하나요?
-
미해결스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술
MVC와 API
안녕하세요!!다름이 아니라 제가 그럼 프론트엔드 기술(react, vue 등)을 모르는데 혼자 화면까지 나오는 프로젝트를 진행하고 싶다면 SSR인 템플릿 엔진을 이용한 MVC패턴으로 개발하는 게 API 방식보다 더 나을까요?? 그러기엔 템플릿 엔진을 사용하더라도 JS나 css는 기본적으로 할 줄 알아야 하는데 ㅜㅜ 따로 JS나 CSS를 배우지 않고서는 혼자서는 무리겠죠?? 아 그리고 MVC 패턴이 SSR방식이고 API가 CSR 방식이라고 이해해도 괜찮을까요??
-
미해결스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술
webapp폴더는 그냥 만들기만 하면 url매핑 안해도 접근이 가능한데 이유가 뭔가요?
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]webapp폴더는 그냥 만들면 url매핑 안해도 접근이 가능한데 이유가 뭔가요?
-
미해결스프링 MVC 2편 - 백엔드 웹 개발 활용 기술
로그인 회원가입에서 더 붙이기
로그인 회원가입 로직만 떼어서, 디자인패턴을 1군데 이용해서 3클래스 이상 변화시킬라고 하는데요추가로 더 보완하는 느낌이에요이 패턴중에서 적용할만한 패턴과, 어디에 적용해야할지 가이드좀 잡아주실 수 있나요?
-
해결됨자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]
MVC vs API
아 아까 MVC와 API의 차이에 대해 질문했었는데요...제가 그럼 프론트엔드 기술 (react, vue 등)을 모르는데 혼자 화면까지 나오는 프로젝트를 진행하고 싶다면 SSR인 템플릿 엔진을 이용한 MVC패턴으로 개발하는 게 더 나을까요??그러기엔 템플릿 엔진을 사용하더라도 JS나 css는 기본적으로 할 줄 알아야 할 거 같은데 ㅜㅜ혼자서는 무리겠죠??
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
generate에 getter sectter이 없어요
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]이게 다예요alt + insert 도 눌러보고 마우스 우클릭하고 접근해봐도 게터섹터가 없네요
-
미해결스프링 시큐리티 완전 정복 [6.x 개정판]
AuthenticationManager에 초기화에 대해 질문있습니다
@Bean public AuthenticationManager authenticationManager(AuthenticationConfiguration configuration) throws Exception { return configuration.getAuthenticationManager(); }위 처럼 Bean 으로 등록하게되면내부 메서드에서 Bean으로 등록된Builder를 통해 등록하는거 까지는 이해했는데요.근데 여기서 setShareObject와 같은게 없는데 return http.build();빌드하게되면 HttpSecurity 메서드의 @Override protected void beforeConfigure() throws Exception { if (this.authenticationManager != null) { setSharedObject(AuthenticationManager.class, this.authenticationManager); } else { ObservationRegistry registry = getObservationRegistry(); AuthenticationManager manager = getAuthenticationRegistry().build(); if (!registry.isNoop() && manager != null) { setSharedObject(AuthenticationManager.class, new ObservationAuthenticationManager(registry, manager)); } else { setSharedObject(AuthenticationManager.class, manager); } } } 가 호출되어 여기서else 조건을 타 getSharedObject 로 AuthenticationManagerBuilder 빌더 클래스를 다시 꺼내와서 빌드를 하는데 이렇게 되면 http.build 과정의 인증관리자와스프링컨테이너에 있는 인증관리자는서로 다른건가요? 같다면 우리가 등록한 Bean이 build 과정에서 나올것같은데못찾겠습니다 ㅠㅠ..
-
해결됨스프링 DB 2편 - 데이터 접근 활용 기술
Itemservice-db와 item service-db-start 두개다 존재하는데 어떤거 여나요?
두개의 폴더가 모두 존재하는데 start의 폴더를 이름변경하여 덮어쓰는것인지 아니면 이미 존재하는 itemservice-db를 오픈하면 되는것인지 혼란이 옵니다.두개의 폴더 모두 오픈해보았는데 db-start폴더는 item클래스가 영상과 같지만 generated폴더가 존재하지 않고 그냥 db 폴더는 item클래스가 영상과 다르지만 generated폴더가 존재합니다 어떤걸 이용하면 되나요?
-
미해결실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
DTO 초기화 관련 질문드립니다.
@Data public class MemberSessionDto { private Long id; private String email; private String password; private String name; private Address address = new Address(); private List<Post> posts; } DTO의 필드 중 데이터가 들어있지 않은 필드가 존재할 수도 있을텐데요, 이럴 때는 new Address()와 같이 초기화를 해주는 것이 좋을까요, 아니면 타임리프에서 th:if="${findMember.address != null}"와 같이 null 처리를 해주는 것이 좋을까요? 도움이 되실까 해서 엔티티 코드도 추가로 첨부하겠습니다.package com.myproject.jpaboard.domain; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import java.util.ArrayList; import java.util.List; @Entity @Getter @Setter @NoArgsConstructor(access = AccessLevel.PUBLIC) public class Member { @Id @GeneratedValue @Column(name = "member_id") private Long id; private String email; private String password; private String name; @Embedded private Address address; @OneToMany(mappedBy = "member", cascade = CascadeType.ALL, fetch = FetchType.LAZY) private List<Post> posts = new ArrayList<>(); @Override public String toString() { return "Member{" + "address=" + address + ", name='" + name + '\'' + ", password='" + password + '\'' + ", email='" + email + '\'' + ", id=" + id + '}'; } }
-
해결됨스프링 시큐리티 완전 정복 [6.x 개정판]
SecurityContextHolderStrategy 설명해주신 부분에서 기존 방식 변경 방식에 대한 질문입니다.
안녕하세요, 24:00 에 말씀해주시는 SecurityContextHolderStrategy 사용하기부분에 기본방식과 변경방식 설명해주시는 부분에서 이해가 안되는 부분이 생겨 질문드립니다.기존방식과 변경방식의 구현된 소스코드를 보니 내부에서(SecurityContextHolder.crateEmptyContext() 내부) 도 결론적으로는 strategy.createEmptyContext() 를 delegate 하는 방식으로 호출 되는것을 보았습니다. 6.x, 5.x, 4.x 모두 동일한듯합니다. /** * Allows retrieval of the context strategy. See SEC-1188. * @return the configured strategy for storing the security context. */ public static SecurityContextHolderStrategy getContextHolderStrategy() { return strategy; } /** * Delegates the creation of a new, empty context to the configured strategy. */ public static SecurityContext createEmptyContext() { return strategy.createEmptyContext(); } AbstractAuthenticationProcessingFilter 쪽에서 successfulAuthentication 쪽에 로직dl 6.x, 5.7 이하 버전 대가 다른단것은 확인했는데 /** * Puts the <code>Authentication</code> instance returned by the authentication * manager into the secure context. */ protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authResult) throws IOException, ServletException { this.logger.debug(LogMessage.format("Authentication success: %s", authResult)); SecurityContext context = this.securityContextHolderStrategy.createEmptyContext(); context.setAuthentication(authResult); this.securityContextHolderStrategy.setContext(context); this.securityContextRepository.saveContext(context, request, response); if (this.eventPublisher != null) { this.eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent(authResult, this.getClass())); } if (this.authenticationSuccessHandler != null) { this.authenticationSuccessHandler.onAuthenticationSuccess(request, response, authResult); } }/** * Puts the <code>Authentication</code> instance returned by the authentication * manager into the secure context. */ protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authResult) throws IOException, ServletException { if (logger.isDebugEnabled()) { logger.debug("Authentication success: " + authResult); } SecurityContextHolder.getContext().setAuthentication(authResult); // Fire event if (this.eventPublisher != null) { eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent( authResult, this.getClass())); } if (authenticationSuccessHandler != null) { authenticationSuccessHandler.onAuthenticationSuccess(request, response, authResult); } }추측건데 strategy 쪽을 세팅할수있는 부분이 추가됨에따라 달라진 부분이라 생각이 되어 이부분도 말씀하신 의도와는 다를듯하여 /** * Sets the {@link SecurityContextHolderStrategy} to use. The default action is to use * the {@link SecurityContextHolderStrategy} stored in {@link SecurityContextHolder}. * * @since 5.8 */ public void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) { Assert.notNull(securityContextHolderStrategy, "securityContextHolderStrategy cannot be null"); this.securityContextHolderStrategy = securityContextHolderStrategy; } 경쟁조건 때문이라고 설명하신 부분에서 말씀하시는 의도를 다시 한번 알수있을까요.
-
미해결자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]
과제 5번 cannot find symbol (sequencedMap) 오류
과제 5 관련 어제자 스레드에 올려주신 파일에서DiceRollResults.java package com.group.libraryapp.day5Practice; import java.util.LinkedHashMap; import java.util.SequencedMap; public class DiceRollResults { private final SequencedMap<Integer, Integer> map = new LinkedHashMap<>(); public DiceRollResults(int maxDiceNumber) { for (int i = 1; i <= maxDiceNumber; i++) { map.put(i, 0); } } public void count(int rollResult) { int updated = map.get(rollResult) + 1; map.replace(rollResult, updated); } public SequencedMap<Integer, Integer> getMap() { return map; } } cannot find symbol (class sequencedMap) 오류가 나는데, 해결방법이 있을까요?
-
미해결자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]
MVC와 API의 차이점
안녕하세요 강사님!!다름이 아니라 공부를 하다가 MVC와 API의 차이점(?)에 대해 알아보게 되었습니다!그래서 내린 결론이Spring MVC구조의 @Controller는 컨트롤러의 리턴값이 ViewResolver에 의해 해석되어서 특정 View가 html응답으로 전송된다.반면 REST API구조의 @RestController에 의한 호출은 View를 리턴하는 것이 목적이 아닌, 데이터를 전송하는 것을 목적으로 응답이 전송되어 진다.라고 내렸습니다.첫번째로, 위에서 제가 내린 결론이 맞는 말인지와두번째로, 그럼 MVC를 쓰는 경우와 API를 쓰는 경우가 언제인지가 궁금합니다.제가 아직 개념이 부족해서 그런건지는 몰라도 MVC를 쓰면 프론트엔드의 역할이 없어지는게(?) 아닌가 하는 착각이 들어서...답변 부탁드리겠습니다!!