묻고 답해요
161만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
OrderApiController
웹 개발 구조에서backend - repository - service - controller - frontend이런 식으로 이해를 하고 있었습니다. 강의를 수강 중 MemberApiController는 MemberService를 의존관계 주입을 받아 Api테스트를 진행하는데 OrderApiController는 왜 Service를 주입받지 않고 Repository를 주입받아 사용하는지 궁금합니다.
-
해결됨실전! Querydsl
페이징 처리 질문
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]지금 질문은 querydsl 뿐만 아니라 spring data jpa도 섞여있습니다. 여태 Spring Data JPA로 페이징을 처리할 때는Page<BoardEntity> findAllByItemItemId(Long itemId, Pageable pageable); @Query(value = "select b from board b " + " join fetch b.member " + " join fetch b.item " + "where b.item.itemId = :itemId" + " order by b.boardId desc ", countQuery = "select count(b) from board b where b.item.itemId = :itemId") Page<BoardEntity> findAllByItemItemId(@Param("itemId") Long itemId, Pageable pageable);이렇게 처리하고서비스에서 // 상품에 대한 문의글 보기 @Transactional(readOnly = true) @Override public Page<BoardDTO> getBoards(Pageable pageable, Long itemId, String email) { // 회원 조회 MemberEntity findUser = memberRepository.findByEmail(email); log.info("유저 : " + findUser); // 상품 조회 ItemEntity findItem = itemRepository.findById(itemId) .orElseThrow(EntityNotFoundException::new); log.info("상품 : " + findItem); // 조회해올 게시글을 넣을 곳 Page<BoardEntity> findAllBoards = boardRepository.findAllByItemItemId(itemId, pageable); // 댓글이 있으면 답변완료, 없으면 미완료 for(BoardEntity boardCheck : findAllBoards) { if(boardCheck.getCommentEntityList().isEmpty()) { boardCheck.changeReply(ReplyStatus.REPLY_X); } else { boardCheck.changeReply(ReplyStatus.REPLY_O); } } for (BoardEntity boardEntity : findAllBoards) { // 파라미터로 받아온 이메일이 있다면 if (email != null) { // 해당 게시글을 만들때 이메일과 조회한 이메일을 체크 // 그리고 맞다면 읽을 권한주고 없으면 잠가주기 if (boardEntity.getMember().getEmail().equals(findUser.getEmail())) { boardEntity.changeSecret(BoardSecret.UN_LOCK); } else { boardEntity.changeSecret(BoardSecret.LOCK); } } else { boardEntity.changeSecret(BoardSecret.LOCK); } } log.info("조회된 게시글 수 : {}", findAllBoards.getTotalElements()); log.info("조회된 게시글 : {}", findAllBoards); return findAllBoards.map(board -> BoardDTO.toBoardDTO( board, board.getMember().getNickName(), board.getItem().getItemId())); } // 상품에 대한 문의글 전체 보기 @GetMapping("") @Tag(name = "board") @Operation(summary = "문의글 전체 보기", description = "모든 상품에 대한 문의글을 봅니다.") public ResponseEntity<?> getBoards( // SecuritConfig에 Page 설정을 한 페이지에 10개 보여주도록 // 설정을 해서 여기서는 할 필요가 없다. @PageableDefault(sort = "boardId", direction = Sort.Direction.DESC) Pageable pageable, @PathVariable(name = "itemId") Long itemId, @RequestParam(value = "email", required = false) String email) { try { log.info("email : " + email); // 검색하지 않을 때는 모든 글을 보여준다. Page<BoardDTO> boards = boardService.getBoards(pageable, itemId, email); Map<String, Object> response = new HashMap<>(); // 현재 페이지의 아이템 목록 response.put("items", boards.getContent()); // 현재 페이지 번호 response.put("nowPageNumber", boards.getNumber()+1); // 전체 페이지 수 response.put("totalPage", boards.getTotalPages()); // 한 페이지에 출력되는 데이터 개수 response.put("pageSize", boards.getSize()); // 다음 페이지 존재 여부 response.put("hasNextPage", boards.hasNext()); // 이전 페이지 존재 여부 response.put("hasPreviousPage", boards.hasPrevious()); // 첫 번째 페이지 여부 response.put("isFirstPage", boards.isFirst()); // 마지막 페이지 여부 response.put("isLastPage", boards.isLast()); return ResponseEntity.ok().body(response); } catch (Exception e) { return ResponseEntity.badRequest().build(); } }이렇게 처리를 했습니다. Page 기능을 사용해서 구현했고 querydsl에서 페이징처리는 다음과 같이 했습니다. @Override public Page<MemberTeamDTO> searchPageComplex(MemberSearchCondition condition, Pageable pageable) { List<MemberTeamDTO> content = queryFactory .select(new QMemberTeamDTO( member.id.as("memberId"), member.userName, member.age, team.id.as("teamId"), team.name.as("teamName"))) .from(member) .leftJoin(member.team, team) .where(userNameEq(condition.getUserName()), teamNameEq(condition.getTeamName()), ageGoe(condition.getAgeGoe()), ageLoe(condition.getAgeLoe())) .offset(pageable.getOffset()) .limit(pageable.getPageSize()) .fetch(); // count 쿼리 (조건에 부합하는 로우의 총 개수를 얻는 것이기 때문에 페이징 미적용) long total = queryFactory // SQL 상으로는 count(member.id)와 동일 .select(member.count()) .from(member) // .leftJoin(member.team, team) .where(userNameEq(condition.getUserName()), teamNameEq(condition.getTeamName()), ageGoe(condition.getAgeGoe()), ageLoe(condition.getAgeLoe())) .fetchOne(); return new PageImpl<>(content, pageable, total); }fetchResult와 fetchCount가 지원을 안한다고 해서 조건에 따라 카운트를 구해서 총 개수를 구해서 하는 방식으로 했는데 이렇게 했을 때도 Map<String, Object> response = new HashMap<>(); // 현재 페이지의 아이템 목록 response.put("items", boards.getContent()); // 현재 페이지 번호 response.put("nowPageNumber", boards.getNumber()+1); // 전체 페이지 수 response.put("totalPage", boards.getTotalPages()); // 한 페이지에 출력되는 데이터 개수 response.put("pageSize", boards.getSize()); // 다음 페이지 존재 여부 response.put("hasNextPage", boards.hasNext()); // 이전 페이지 존재 여부 response.put("hasPreviousPage", boards.hasPrevious()); // 첫 번째 페이지 여부 response.put("isFirstPage", boards.isFirst()); // 마지막 페이지 여부 response.put("isLastPage", boards.isLast());이런식으로 뽑아서 프론트에 보낼 수 있는지와실무에서도 spring data jpa와 querydsl 방식으로 페이징 처리를 할 때 이렇게 하는지 아니면 다른 방식이 더있는지 궁금해서 질문드립니다.
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
<p>태그 관련 질문
1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]여기에 질문 내용을 남겨주세요.프론트 p태그 관련 질문입니다.데이터를 집어 넣지 않고 단순하게 쓰는 p태그의 경우<p>인프런</p> 코드를 실행하면 인프런이 출력되는걸로 알고 있습니다. 강의를 듣다 호기심에 나이스 문자열을 추가해봤는데요나이스1은 타임리프 문법이 적용된 문장이고나이스는 단순한 p태그입니다.하지만 나이스1도 타임리프 관련 코드가 끝나고 괄호를 닫고 추가된 문자인데 왜 출력이 안 되는지 궁금합니다.
-
해결됨스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
윈도우 gradlew.bat build 에러 발생
Microsoft Windows [Version 10.0.22621.2861] (c) Microsoft Corporation. All rights reserved. C:\Users\Yoon\Desktop\CS\SpringStudy\hello-spring>gradlew build FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'hello-spring'. > Could not resolve all files for configuration ':classpath'. > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.2.1. Required by: project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.2.1 > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.2.1 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.5' but: - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.1 declares a library, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') - Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.1 declares a component for use during runtime, and its dependencies declared externally: - Incompatible because this component declares documentation and the consumer needed a library - Other compatible attributes: - Doesn't say anything about its target Java version (required compatibility with Java 8) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') - Variant 'mavenOptionalApiElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.2.1 declares a library, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') - Variant 'mavenOptionalRuntimeElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.2.1 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') - Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.1 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') - Variant 'sourcesElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.1 declares a component for use during runtime, and its dependencies declared externally: - Incompatible because this component declares documentation and the consumer needed a library - Other compatible attributes: - Doesn't say anything about its target Java version (required compatibility with Java 8) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') * Try: > Run with --stacktrace option to get the stack trace. > 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. BUILD FAILED in 5s 안녕하세요 어제 동일한 질문을 올렸었는데 파일의 권한을 수정하고 다시 올렸습니다.우선 저는 윈도우 사용자이고, java --version으로 확인해봐도 Java 17버전이고, 설정 가능한 모든 부분에서 17버전으로 바꿨는데도 에러가 발생합니다. 모든 방법을 시도해봐도 cmd에서 "gradlew build" 명령어를 치면 build failed라는 메시지가 출력됩니다. plugins { id 'java' id 'org.springframework.boot' version '3.2.1' id 'io.spring.dependency-management' version '1.1.4' } group = 'hello' version = '0.0.1-SNAPSHOT' java { sourceCompatibility = '17' } repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' testImplementation 'org.springframework.boot:spring-boot-starter-test' } tasks.named('test') { useJUnitPlatform() } 파일 링크: https://drive.google.com/file/d/1hnY1DJJ-9loR_mcQBum97NDgOErGgoMO/view?usp=sharing며칠째 이부분에서 막혀서 진도를 못 나가고 있습니다.. 도와주세요..ㅠㅠ------------------------------------------------------------------------------------------------java 17버전으로 설정해도 오류가 나시는 분들이 계시다면 아래 방법을 따라해보세요. 저는 이렇게 하니 해결되었습니다.인텔리제이 최신버전으로 재설치기존 JDK 삭제 후 최신버전으로 재설치 및 환경변수 등록 (재부팅 필수) 설치한 JDK를 프로젝트에 적용
-
해결됨김영한의 실전 자바 - 기본편
static class
안녕하세요 강사님!static class는 후속강의에서 다뤄주시나요?
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
섹션 5-2. JPA에서 em.createQuery(SQL) 질문
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]여기에 질문 내용을 남겨주세요. JPA에서 em.createQuery("select i from Item i", ...)을 쓰시는데 저 구문을 h2에 직접 날려보면 i 를 찾을 수 없다고 나오는데 select * from item을 안 쓰는 이유가 있나요?
-
해결됨나도코딩의 자바 기본편 - 풀코스 (20시간)
퀴즈 12번 질문있습니다.
퀴즈 12번에서 아래와 같이 코드를 작성했는데,실행 결과가 계속 해도 순차적으로 나옵니다..public static void main(String[] args) { Runnable product1 = () -> { for (int i = 1; i <= 5 ; i++) { System.out.println("A 상품 준비 " + i + "/5"); } System.out.println("-- A 상품 준비 완료 --"); }; Runnable product2 = () -> { for (int i = 1; i <= 5 ; i++) { System.out.println("B 상품 준비 " + i + "/5"); } System.out.println("-- B 상품 준비 완료 --"); }; Thread ProductThread1 = new Thread(product1); Thread ProductThread2 = new Thread(product2); ProductThread1.start(); ProductThread2.start(); while(ProductThread1.isAlive() || ProductThread2.isAlive()){ } /*try { ProductThread1.join(); ProductThread2.join(); } catch (InterruptedException e) { throw new RuntimeException(e); }*/ Runnable packing = () -> { System.out.println(" == 상품 준비 시작 == "); for (int i = 1; i <= 5; i++) { System.out.println("세트 상품 포장" + i + "/5"); } System.out.println(" == 상품 준비 끝 == "); }; Thread ProductPacking = new Thread(packing); ProductPacking.start(); }A실행이 끝나고 B로 넘어가는데,, 왜 그런걸까요.. 뭐가 문제일까요.. 강의와 똑같이 작성했는데.. A 상품 준비 1/5A 상품 준비 2/5A 상품 준비 3/5A 상품 준비 4/5A 상품 준비 5/5-- A 상품 준비 완료 --B 상품 준비 1/5B 상품 준비 2/5B 상품 준비 3/5B 상품 준비 4/5B 상품 준비 5/5-- B 상품 준비 완료 --== 상품 준비 시작 ==세트 상품 포장1/5세트 상품 포장2/5세트 상품 포장3/5세트 상품 포장4/5세트 상품 포장5/5== 상품 준비 끝 == 이런 식으로 나오거나 A와 B의 순서만 바뀔 뿐 숫자가 ABABAAB 이런식으로 섞이지가 않습니다..AAAAABBBBB 또는 BBBBBAAAAA이런식으로 나와요.. 아니면 AAAAAB(A준비완료)BBBB 이런식으로도 안나옵니다.. 무조건 한 상품 5개 모두 실행완료 후 다음 상품 실행해요..
-
미해결자바 ORM 표준 JPA 프로그래밍 - 기본편
em.detach 메서드와 관련하여 질문드립니다.
위의 로직을 보시면Member 객체를 생성후 persist() 메서드를 호출한 후에 detach() 메서드를 호출하였습니다.그러면 제 생각에는 persist()를 호출한 순간에 쓰기지연 SQL저장소에 insert문이 있기 때문에 flush하면 insert 쿼리가 console에 나와야하는데 왜 안나오는지 이유를 모르겠습니다.혹시 detach를하면 쓰기 지연 SQL저장소에 있는 insert가 사라지는건가요?
-
해결됨김영한의 실전 자바 - 기본편
문제풀이 응용버전
안녕하세요. 문제풀이를 보다보니 접근제어자 강의가 접근제어자에 관한 강의인 것인지 아님 만든 클래스를 바탕으로 접근제어자를 통해서 불러 들이는 것에 관한 내용인지 헷갈리지만 계속 강의를 들으면서 이해하려고 노력 중입니다. 회원의 닉네임과 주소를 받아 저장하는 형식의 로직과 주문할 음식 그리고 해당 음식의 가격과 수량을 받아서 출력문을 만들었습니다.닉네임과 주소를 입력하지 않고 enter를 했을 때 다시 입력하라는 구문과 함께 재입력을 받게 하고 싶은데 아래의 결과처럼 나오게 됩니다. 어떤 부분에서 오류가 있는지 잘 모르겠습니다. return; 도 사용해봤지만 동일하게 나오더군요.
-
해결됨실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
@Transactional 과 entityManager 범위에 관해 질문 드립니다.
안녕하세요! 강의 수강 중 질문이 생겨 작성합니다.. 답변 부탁드립니다..!ㅠ.ㅠ -- MemberRepository 입니다. ( @Transactional 키워드 모두 지움 )@Repository public class MemberRepository { @PersistenceContext EntityManager em; public Member findMember( Long id ) { Member member = em.find(Member.class, id); return member; } public Member findMember2( Long id ) { Member member = em.find(Member.class, id); return member; } } -- 위 레파지토리를 호출하는 테스트 코드 입니다. ( 데이터는 미리 넣어둔 상태 입니다. )@SpringBootTest class MemberRepositoryTest { @Autowired MemberRepository mRepo; @Test public void test2() { System.out.println("================================================="); System.out.println(mRepo.getClass()); //when Member found1 = mRepo.findMember(1L); Member found2 = mRepo.findMember2(1L); System.out.println("================================================="); //then assertEquals(found2, found1); } } 1 ) 테스트 코드에서 주입받은 mRepo의 클래스 타입을 확인하면 CGLIB로 생성한 프록시 클래스가 출력됩니다. 위 코드에서 보는 바와 같이 @Transactional 어노테이션은 존재하지 않는데도 실 클래스가 아닌 프록시 객체로 만들어지는 이유가 뭔가요?? 2 ) 테스트 코드에서 test2()를 실행하면 select를 2번 실행합니다. test2()에 @Transactional을 걸면 -> select 1번 -> 너무 당연한데MemberRepo 클래스 레벨에서 @Transactional -> 테스트 코드 실행 시 select 2번MemberRepo 클래스 각 메소드에 @Transactional -> 테스트 코드 실행 시 select 2번 2-1) 위와 같은 결과가 발생하는 이유를 모르겠습니다.. @Transactional을 어떻게 걸든 한 메소드가 종료하고 나면 PersistenceContext 가 닫히는 건가요?.. 2-2) MemberRepo 에서 주입받은 entityManager는 proxy 클래스가 맞는거죠..?@Transactional을 표기해주지 않아도, em을 사용하는 메소드가 호출되고 종료 될 때마다, 매번 proxy 객체 내부의 실제 entityManager 객체가 변경되는 건가요?? 2-3) em.find(Member.class, 1L) 같은 조회성 질의에서@Transactional(readOnly=true) 와 아예 해당 어노테이션을 사용하지 않았을 경우의 결과가 동일하였습니다. 그렇다면 readOnly를 사용하는 이유가 대체 무엇인가요?.. 질문이 많아서 죄송합니다 ㅠㅠ 머리에 정리가 되질 않아서요..답변 부탁드립니다!!
-
해결됨[자바/Java] 문과생도 이해하는 DFS 알고리즘! - 입문편
재귀대신 스택으로 구현하면 안될까요?
이 문제의 재귀는 이해가 됬지만, 다른 문제들에서 마주치는 재귀함수들은 손이 잘 안가고, 항상 남의코드를 봐야만 이해가 되더라구요.여기서 dfs함수를 스택으로 구현하면 라인이 더 길어져 재귀보다는 깔끔하지가 않은데, 이해 및 구현이 쉬운거 보다 명확한거 같은데, 코딩테스트의 재귀들은 모두 스택으로 구현하면 어떨지 궁금합니다.
-
해결됨김영한의 실전 자바 - 기본편
다형성과 캐스팅 질문입니다
처음엔 자식타입이 부모타입보다 더 큰 범위라서 부모 인스턴스는 자식 인스턴스를 참조할 수 있다고 이해했습니다. 또한 강의자료에도 자식 클래스를 참조할 때 자식 인스턴스 안에 부모 인스턴스의 부분과 자식인스턴스의 부분이 나뉘어져있는거라고 나와 있어 그대로 이해했었는데요. 강의에선부모가 자식을 담을 수 있다 (O)자식은 부모를 담을 수 없다(O)이렇게 되어있어 헷갈려서 질문드립니다...(+ 그리고 다운캐스팅은 복사한 값을 캐스팅하는 것이므로 일시적으로만 실행되는게 맞나요?)=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]여기에 질문 내용을 남겨주세요.
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
강의 자료 오타 제보합니다.
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오) 예2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 예3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) 예[질문 내용]3. 회원 관리 예제 - 백엔드 개발.pdf5번째 페이지MemoryMemberRepositoryTest 클래스의 save() 메서드 부분이 이렇게 되어 있습니다. 마지막 줄이 수정이 필요해 보입니다.@Test public void save() { //given Member member = new Member(); member.setName("spring"); //when repository.save(member); //then Member result = repository.findById(member.getId()).get(); (result).isEqualTo(member); }
-
미해결코딩으로 학습하는 GoF의 디자인 패턴
Spring Security 의 ProviderManager (AuthenticationManager) 도 옵저버 패턴을 사용하고 있다고 볼 수 있을까요?
안녕하세요 강사님! 우선 양질의 강의 잘 듣고 있다는 말씀 드리고 싶습니다. Spring Security 에서 AuthenticationProvider 를 찾아서 인증을 위임하는 역할을 수행하는 ProviderManger 도 옵저버 패턴을 사용하고있다고 볼 수 있을까요? ProviderManager (AuthenticationManager) 에서 AuthenticationProvider 들을 가져온후 이들을 순회하며 인증위임을 시키는 코드입니다단순히 supports() 를 통해 인증을 위임시킬 AuthenticationProvider 들을 골라내는 것뿐, 이것도 옵저버 패턴이 적용된 예인지 알고 싶습니다.
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
윈도우 gradlew.bat build 에러 발생
C:\Users\Yoon>cd C:\Users\Yoon\Desktop\CS\SpringStudy\hello-spring C:\Users\Yoon\Desktop\CS\SpringStudy\hello-spring>gradlew.bat build FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'hello-spring'. > Could not resolve all files for configuration ':classpath'. > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.2.1. Required by: project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.2.1 > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.2.1 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.5' but: - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.1 declares a library, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') - Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.1 declares a component for use during runtime, and its dependencies declared externally: - Incompatible because this component declares documentation and the consumer needed a library - Other compatible attributes: - Doesn't say anything about its target Java version (required compatibility with Java 8) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') - Variant 'mavenOptionalApiElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.2.1 declares a library, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') - Variant 'mavenOptionalRuntimeElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.2.1 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') - Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.1 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') - Variant 'sourcesElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.1 declares a component for use during runtime, and its dependencies declared externally: - Incompatible because this component declares documentation and the consumer needed a library - Other compatible attributes: - Doesn't say anything about its target Java version (required compatibility with Java 8) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') * Try: > Run with --stacktrace option to get the stack trace. > 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. BUILD FAILED in 5s"빌드하고 실행하기" 강의에서 위 에러가 발생하였습니다.우선 저는 윈도우 사용자입니다.java --version으로 확인해봐도 Java 17버전이고, 설정 가능한 모든 부분에서 17버전으로 바꿨는데도 에러가 발생합니다. 파일 링크 : https://drive.google.com/file/d/1hnY1DJJ-9loR_mcQBum97NDgOErGgoMO/view?usp=drive_link
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
h2db에 입력후 localhost 조회시 안나옴
https://drive.google.com/file/d/1bWQeZq1FfiqL2cIEU7zJu-_Td0NSqGwF/view?usp=drive_link
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
Transaction과 영속성 컨텍스트
안녕하세요. 강의 전반을 보고 영속성 컨텍스트에 대한 궁금증이 있어 이것 저것 테스트 해보다가 질문 남깁니다.기본적으로 Spring Data JPA에서 제공하는 영속성 컨텍스트는 1.Transaction 단위로 생성되는 것으로 이해하고 있었습니다.또한, 서로 다른 영속성 컨텍스트에 대해서 1차 캐시를 공유하지 않는것으로 알 고 있어, 서로 다른 2개의 @transaction에 대해서는 같은 값을 조회하더라도 동등성을 보장하지 않을것이라고 생각합니다.먼저, 위에 대한 제 생각이 맞는지 궁금합니다. 두 번째로 제가 직접 Application을 띄우고 하나의 http 요청에 대해 서로 다른 2개의 @transaction을 처리하는 로직을 넣고 서로 다른 @transaction에서 같은 값을 조회 후 동등성을 테스트 해봤는데 동등하다는 결과가 반복되었습니다. 이에 혹시 위에서 언급한 1.Transaction이 http 요청 단위의 transaction을 의미하는 것인가 라는 궁금증이 들었습니다. 위 2개 질문 이외 혹시 제가 놓치거나 잘못 이해한 부분이 있다면 알려주시길 바랍니다.감사합니다.
-
해결됨실전! Querydsl
Hello 테이블 생성 안됨..
안녕하세요.. Hello Table이 생성이 안돼서 질문 드립니다. 모든 코드는 강의자료에 있는 코드를 복붙했습니다. (에러가 나서 ..) test코드를 돌려보면 에러는 안나는데 h2db테이블에서 생성이 안됩니다.에러 코드 > Task :compileJava UP-TO-DATE > Task :processResources > Task :classes > Task :compileTestJava > Task :processTestResources NO-SOURCE > Task :testClasses > Task :test 15:47:24.714 [Test worker] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils -- Could not detect default configuration classes for test class [study.querydsl.QuerydslApplicationTests]: QuerydslApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration. 15:47:24.762 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper -- Found @SpringBootConfiguration study.querydsl.QuerydslApplication for test class study.querydsl.QuerydslApplicationTests . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v3.2.0) 2024-01-02T15:47:24.972+09:00 INFO 14318 --- [ Test worker] s.querydsl.QuerydslApplicationTests : Starting QuerydslApplicationTests using Java 17.0.6 with PID 14318 (started by gaheechoi in /Users/gaheechoi/Desktop/휴학/백앤드/querydsl) 2024-01-02T15:47:24.973+09:00 INFO 14318 --- [ Test worker] s.querydsl.QuerydslApplicationTests : No active profile set, falling back to 1 default profile: "default" 2024-01-02T15:47:25.274+09:00 INFO 14318 --- [ Test worker] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2024-01-02T15:47:25.285+09:00 INFO 14318 --- [ Test worker] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 7 ms. Found 0 JPA repository interfaces. 2024-01-02T15:47:25.532+09:00 INFO 14318 --- [ Test worker] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2024-01-02T15:47:25.557+09:00 INFO 14318 --- [ Test worker] org.hibernate.Version : HHH000412: Hibernate ORM core version 6.3.1.Final 2024-01-02T15:47:25.573+09:00 INFO 14318 --- [ Test worker] o.h.c.internal.RegionFactoryInitiator : HHH000026: Second-level cache disabled 2024-01-02T15:47:25.685+09:00 INFO 14318 --- [ Test worker] o.s.o.j.p.SpringPersistenceUnitInfo : No LoadTimeWeaver setup: ignoring JPA class transformer 2024-01-02T15:47:25.700+09:00 INFO 14318 --- [ Test worker] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2024-01-02T15:47:25.796+09:00 INFO 14318 --- [ Test worker] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection conn0: url=jdbc:h2:mem:a21f98cc-44fd-4380-bad2-49c71d2c5ced user=SA 2024-01-02T15:47:25.797+09:00 INFO 14318 --- [ Test worker] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2024-01-02T15:47:25.908+09:00 INFO 14318 --- [ Test worker] p6spy : #1704178045908 | took 3ms | statement | connection 1| url jdbc:h2:mem:a21f98cc-44fd-4380-bad2-49c71d2c5ced select * from INFORMATION_SCHEMA.SEQUENCES select * from INFORMATION_SCHEMA.SEQUENCES; 2024-01-02T15:47:26.178+09:00 INFO 14318 --- [ Test worker] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration) 2024-01-02T15:47:26.186+09:00 DEBUG 14318 --- [ Test worker] org.hibernate.SQL : drop table if exists hello cascade 2024-01-02T15:47:26.187+09:00 INFO 14318 --- [ Test worker] p6spy : #1704178046187 | took 0ms | statement | connection 2| url jdbc:h2:mem:a21f98cc-44fd-4380-bad2-49c71d2c5ced drop table if exists hello cascade drop table if exists hello cascade ; 2024-01-02T15:47:26.187+09:00 DEBUG 14318 --- [ Test worker] org.hibernate.SQL : drop sequence if exists hello_seq 2024-01-02T15:47:26.187+09:00 INFO 14318 --- [ Test worker] p6spy : #1704178046187 | took 0ms | statement | connection 2| url jdbc:h2:mem:a21f98cc-44fd-4380-bad2-49c71d2c5ced drop sequence if exists hello_seq drop sequence if exists hello_seq; 2024-01-02T15:47:26.189+09:00 DEBUG 14318 --- [ Test worker] org.hibernate.SQL : create sequence hello_seq start with 1 increment by 50 2024-01-02T15:47:26.191+09:00 INFO 14318 --- [ Test worker] p6spy : #1704178046191 | took 1ms | statement | connection 3| url jdbc:h2:mem:a21f98cc-44fd-4380-bad2-49c71d2c5ced create sequence hello_seq start with 1 increment by 50 create sequence hello_seq start with 1 increment by 50; 2024-01-02T15:47:26.192+09:00 DEBUG 14318 --- [ Test worker] org.hibernate.SQL : create table hello (id bigint not null, primary key (id)) 2024-01-02T15:47:26.194+09:00 INFO 14318 --- [ Test worker] p6spy : #1704178046194 | took 1ms | statement | connection 3| url jdbc:h2:mem:a21f98cc-44fd-4380-bad2-49c71d2c5ced create table hello (id bigint not null, primary key (id)) create table hello (id bigint not null, primary key (id)); 2024-01-02T15:47:26.195+09:00 INFO 14318 --- [ Test worker] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2024-01-02T15:47:26.268+09:00 WARN 14318 --- [ Test worker] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning 2024-01-02T15:47:26.478+09:00 INFO 14318 --- [ Test worker] s.querydsl.QuerydslApplicationTests : Started QuerydslApplicationTests in 1.645 seconds (process running for 2.13) 2024-01-02T15:47:26.801+09:00 DEBUG 14318 --- [ Test worker] org.hibernate.SQL : select next value for hello_seq 2024-01-02T15:47:26.803+09:00 INFO 14318 --- [ Test worker] p6spy : #1704178046803 | took 0ms | statement | connection 4| url jdbc:h2:mem:a21f98cc-44fd-4380-bad2-49c71d2c5ced select next value for hello_seq select next value for hello_seq; 2024-01-02T15:47:26.974+09:00 DEBUG 14318 --- [ Test worker] org.hibernate.SQL : insert into hello (id) values (?) 2024-01-02T15:47:26.976+09:00 INFO 14318 --- [ Test worker] p6spy : #1704178046976 | took 0ms | statement | connection 4| url jdbc:h2:mem:a21f98cc-44fd-4380-bad2-49c71d2c5ced insert into hello (id) values (?) insert into hello (id) values (1); 2024-01-02T15:47:26.986+09:00 DEBUG 14318 --- [ Test worker] org.hibernate.SQL : select h1_0.id from hello h1_0 2024-01-02T15:47:26.987+09:00 INFO 14318 --- [ Test worker] p6spy : #1704178046987 | took 0ms | statement | connection 4| url jdbc:h2:mem:a21f98cc-44fd-4380-bad2-49c71d2c5ced select h1_0.id from hello h1_0 select h1_0.id from hello h1_0; 2024-01-02T15:47:27.014+09:00 INFO 14318 --- [ Test worker] p6spy : #1704178047014 | took 0ms | rollback | connection 4| url jdbc:h2:mem:a21f98cc-44fd-4380-bad2-49c71d2c5ced ; OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended 2024-01-02T15:47:27.025+09:00 INFO 14318 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' 2024-01-02T15:47:27.026+09:00 INFO 14318 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2024-01-02T15:47:27.027+09:00 INFO 14318 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. > Task :test 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.5/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation. BUILD SUCCESSFUL in 3s 4 actionable tasks: 3 executed, 1 up-to-date 3:47:27 PM: Execution finished ':test --tests "study.querydsl.QuerydslApplicationTests"'. h2 db는 기존의 1.4 xx 대를 사용하다, spring boot3로 올리면서 강의자료 대로 2.2.224로 바꾸었습니다.db 생성은 잘 되었고, tcp로 db접근도 완료 했습니다.생성이 안되는 이유를 모르겠습니다 ㅠㅠ... tcp 접근 QHello 위치 application.yml
-
해결됨실전! Querydsl
Q파일 생성 위치 질문
안녕하세요현재 프로젝트 세팅 및 테스트를 진행 중입니다. spring boot가 3이상으로 제한된 상황속에서 진행중이며, 강의 내용을 따라하고 있습니다! build.gradle은 https://docs.google.com/document/d/1j0jcJ9EoXMGzwAA2H0b9TOvRtpwlxI5Dtn3sRtuXQas/edit#heading=h.vfy9wirpglmx를 복/붙 하였습니다.plugins { id 'java' id 'org.springframework.boot' version '3.2.0' id 'io.spring.dependency-management' version '1.1.4' } group = 'study' version = '0.0.1-SNAPSHOT' sourceCompatibility = '17' configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.9.0' compileOnly 'org.projectlombok:lombok' runtimeOnly 'com.h2database:h2' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' //test 롬복 사용 testCompileOnly 'org.projectlombok:lombok' testAnnotationProcessor 'org.projectlombok:lombok' //Querydsl 추가 implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta" annotationProcessor "jakarta.annotation:jakarta.annotation-api" annotationProcessor "jakarta.persistence:jakarta.persistence-api" } tasks.named('test') { useJUnitPlatform() } clean { delete file('src/main/generated') } 질문은 크게 3가지입니다. build/other/compileQuerydsl은 표기가 안되는데 다른 답변을 보니 springboot3으로 올라가며 compileQuerydsl은 표기가 안된다고 하신 것 같은데 맞을까요?정확한 Q파일의 생성 위치가 궁굼합니다.!강의상에서는 src/main에 둬도 괜찮지만, 버전관리 시스템(git)에는 추가 되지 않는게 좋다고 하셨던 것 같은데 맞나요?build에만 Q파일이 생성되는게 좋나요?올려주신 google doc의 build.gradle로 진행하면, Q파일이 build/annotationProcessor아래 생성됩다... 뭐가 문제일까요? docs에 올려주신 build.gradle에서 build clean을 진행할 때 'src/main/generated'의 폴더를 삭제하는 이유가 무엇일까요? (현재 저는 Q파일을 build/ 아래 관리하고있는데, src/main/generate 아래 Q파일을 생성하시는 분들에만 해당 되는 내용인가요?)답변해주시면 감사하겠습니다!
-
해결됨자바 ORM 표준 JPA 프로그래밍 - 기본편
엔티티 변경 후 일대다
@JoinColumn(name = "MEMBER_ID) List<AddressEntity> addressHistory = ..다대일이 아닌 일대다로 매핑한 이유가 있을까요?앞에서 다쪽에 @JoinColumn하는 것을 추천하셨는데 일쪽에 연관관계 주인을 잡은 이유가 궁금합니다.