inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

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

3.2 공통원소 구하기 에서 질문입니다.

미해결

자바(Java) 알고리즘 문제풀이 입문: 코딩테스트 대비

샘플문제는 정답인데, 채점사이트에서는 오답으로 나오네요. 어디가 잘못되었는지 못찾겠습니다. import java.util.*; class Main { public ArrayList<Integer> solution( int n , int [] arr1 , int m , int [] arr2 ) { ArrayList<Integer> answer = new ArrayList<>(); Arrays. sort ( arr1 ); Arrays. sort ( arr2 ); int p1 =0, p2 =0; while ( p1 < n && p2 < m ) { if ( arr1 [ p1 ]== arr2 [ p2 ]) { answer .add( arr1 [ p1 ]++); p2 ++; } else if ( arr1 [ p1 ]< arr2 [ p2 ]) p1 ++; else p2 ++; } return answer ; }

  • java
  • 코딩-테스트
sulgiro.kwak 댓글 1 좋아요 0 조회수 135

상속시 메모리 구조와 @Overriding 어노테이션 관련 질문 드립니다.

미해결

김영한의 실전 자바 - 기본편

안녕하세요. 좋은 강의 정말 재미있게 잘 수강하고 있습니다. '상속과 메서드 오버라이딩' 강의 내용 관련하여 궁금한 점이 생겨 질문 드립니다. A와 B는 강의에서 설명해주신 내용입니다. [A.상속시 메모리 구조] 상속한 클래스의 메서드를 호출하는 경우에 1)본인 타입에서 해당 메서드를 먼저 찾고 2-1) 없으면 부모 타입에서 찾는다 2-2) 있으면 종료 [B. @Overriding] 자식 클래스의 메서드에 @Overriding 애노테이션을 붙여 오버라이딩 수행 시, 부모 클래스에 해당 메서드가 존재하지 않으면 컴파일 오류가 발생 그런데 여기에서 B 처럼 동작하려면 A의 2-2 경우에 자식 타입만 조사하고 종료하는 것이 아니라, 컴파일 타임에 부모 클래스의 메서드도 조사해야하지 않나요? @Overriding 애노테이션을 사용했을 때 실제로 어떤식으로 동작하는지 궁금합니다. 감사합니다.

  • java
  • 객체지향
  • 오버라이딩
devocean 댓글 1 좋아요 0 조회수 274

D-Day 앱 만들기에서 에러가 나옵니다ㅠㅠ

미해결

자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]

하나는 "NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null" 이런 에러인거 같은데....대체 어디서 잘못된걸까요. 에러가 여러개 인건가요? FAILURE: Build completed with 2 failures. 1: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:checkDebugAarMetadata'. > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction > 5 issues were found when checking AAR metadata: * Try: > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. * Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:checkDebugAarMetadata'. Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction Caused by: java.lang.RuntimeException: 5 issues were found when checking AAR metadata: 1. Dependency 'androidx.appcompat:appcompat-resources:1.7.0' requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs. :app is currently compiled against android-33. Also, the maximum recommended compile SDK version for Android Gradle plugin 8.0.0 is 33. Recommended action: Update this project's version of the Android Gradle plugin to one that supports 34, then update this project to use compileSdk of at least 34. Note that updating a library or application's compileSdk (which allows newer APIs to be used) can be done separately from updating targetSdk (which opts the app in to new runtime behavior) and minSdk (which determines which devices the app can be installed on). 2. Dependency 'androidx.appcompat:appcompat:1.7.0' requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs. :app is currently compiled against android-33. Also, the maximum recommended compile SDK version for Android Gradle plugin 8.0.0 is 33. Recommended action: Update this project's version of the Android Gradle plugin to one that supports 34, then update this project to use compileSdk of at least 34. Note that updating a library or application's compileSdk (which allows newer APIs to be used) can be done separately from updating targetSdk (which opts the app in to new runtime behavior) and minSdk (which determines which devices the app can be installed on). 3. Dependency 'androidx.core:core-ktx:1.13.0' requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs. :app is currently compiled against android-33. Also, the maximum recommended compile SDK version for Android Gradle plugin 8.0.0 is 33. Recommended action: Update this project's version of the Android Gradle plugin to one that supports 34, then update this project to use compileSdk of at least 34. Note that updating a library or application's compileSdk (which allows newer APIs to be used) can be done separately from updating targetSdk (which opts the app in to new runtime behavior) and minSdk (which determines which devices the app can be installed on). 4. Dependency 'androidx.core:core:1.13.0' requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs. :app is currently compiled against android-33. Also, the maximum recommended compile SDK version for Android Gradle plugin 8.0.0 is 33. Recommended action: Update this project's version of the Android Gradle plugin to one that supports 34, then update this project to use compileSdk of at least 34. Note that updating a library or application's compileSdk (which allows newer APIs to be used) can be done separately from updating targetSdk (which opts the app in to new runtime behavior) and minSdk (which determines which devices the app can be installed on). 5. Dependency 'androidx.annotation:annotation-experimental:1.4.0' requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs. :app is currently compiled against android-33. Also, the maximum recommended compile SDK version for Android Gradle plugin 8.0.0 is 33. Recommended action: Update this project's version of the Android Gradle plugin to one that supports 34, then update this project to use compileSdk of at least 34. Note that updating a library or application's compileSdk (which allows newer APIs to be used) can be done separately from updating targetSdk (which opts the app in to new runtime behavior) and minSdk (which determines which devices the app can be installed on). ============================================================================== 2: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:mergeExtDexDebug'. > Could not resolve all files for configuration ':app:debugRuntimeClasspath'. > Failed to transform appcompat-resources-1.7.0.aar (androidx.appcompat:appcompat-resources:1.7.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. > Execution failed for DexingNoClasspathTransform: C:\Users\abc14\.gradle\caches\transforms-3\c494794d48d9429ce3837ff3d9162578\transformed\appcompat-resources-1.7.0-runtime.jar. > Error while dexing. > Failed to transform appcompat-1.7.0.aar (androidx.appcompat:appcompat:1.7.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. > Execution failed for DexingNoClasspathTransform: C:\Users\abc14\.gradle\caches\transforms-3\d251d80cfc588f74172158875c7b2196\transformed\appcompat-1.7.0-runtime.jar. > Error while dexing. * Try: > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. * Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:mergeExtDexDebug'. Caused by: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null Caused by: java.util.concurrent.ExecutionException: com.android.tools.r8.utils.P0: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null Caused by: [CIRCULAR REFERENCE: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null] Cause 2: org.gradle.api.internal.artifacts.transform.TransformException: Failed to transform appcompat-1.7.0.aar (androidx.appcompat:appcompat:1.7.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. Caused by: org.gradle.api.internal.artifacts.transform.TransformException: Execution failed for DexingNoClasspathTransform: C:\Users\abc14\.gradle\caches\transforms-3\d251d80cfc588f74172158875c7b2196\transformed\appcompat-1.7.0-runtime.jar. Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing. at com.android.builder.dexing.D8DexArchiveBuilder.getExceptionToRethrow(D8DexArchiveBuilder.java:189) Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Users\abc14\.gradle\caches\transforms-3\d251d80cfc588f74172158875c7b2196\transformed\appcompat-1.7.0-runtime.jar:androidx/appcompat/app/ActionBarDrawerToggle$1.class Caused by: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null Suppressed: java.lang.RuntimeException: java.util.concurrent.ExecutionException: com.android.tools.r8.utils.P0: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null Caused by: java.util.concurrent.ExecutionException: com.android.tools.r8.utils.P0: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null Caused by: com.android.tools.r8.utils.P0: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null Caused by: [CIRCULAR REFERENCE: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null]

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

질문있습니다!

해결됨

자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]

10:49초 에 질문이 있습니다. userRepository.findById(request.getId()) 를 하면 왜 optional<User>가 나오는 건지 알수있나요?

  • java
  • spring
  • aws
  • mysql
  • spring-boot
  • jpa
김병곤 댓글 1 좋아요 0 조회수 152

insert로그 확인 후 h2 db에 값이 안나옵니다..

해결됨

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

[질문 내용] 여기에 질문 내용을 남겨주세요. 강의 11분쯤 insert 로그 확인 후 h2 db에 들어가 값이 들어가는지 확인을 하는데요 저도 로그에서 insert문 확인 후 h2 db에 들어 갔는데 값이 계속 안 나와 질문 올립니다. 밑에는 로그 내역이고 구글 드라이브 링크도 같이 올립니다. 2024-06-20T21:12:05.260+09:00 DEBUG 21664 --- [ Test worker] org.hibernate.SQL : select m1_0.member_id, m1_0.city, m1_0.street, m1_0.zipcode, m1_0.name from member m1_0 where m1_0.name=? 2024-06-20T21:12:05.276+09:00 INFO 21664 --- [ Test worker] p6spy : #1718885525275 | took 7ms | statement | connection 3| url jdbc:h2:mem:7cd22d26-ead4-4150-987b-79b62bd18ed5 select m1_0.member_id,m1_0.city,m1_0.street,m1_0.zipcode,m1_0.name from member m1_0 where m1_0.name=? select m1_0.member_id,m1_0.city,m1_0.street,m1_0.zipcode,m1_0.name from member m1_0 where m1_0.name='kim'; 2024-06-20T21:12:05.289+09:00 DEBUG 21664 --- [ Test worker] org.hibernate.SQL : select next value for member_seq 2024-06-20T21:12:05.292+09:00 INFO 21664 --- [ Test worker] p6spy : #1718885525292 | took 1ms | statement | connection 3| url jdbc:h2:mem:7cd22d26-ead4-4150-987b-79b62bd18ed5 select next value for member_seq select next value for member_seq; 2024-06-20T21:12:05.336+09:00 DEBUG 21664 --- [ Test worker] org.hibernate.SQL : insert into member (city, street, zipcode, name, member_id) values (?, ?, ?, ?, ?) 2024-06-20T21:12:05.340+09:00 INFO 21664 --- [ Test worker] p6spy : #1718885525340 | took 0ms | statement | connection 3| url jdbc:h2:mem:7cd22d26-ead4-4150-987b-79b62bd18ed5 insert into member (city,street,zipcode,name,member_id) values (?,?,?,?,?) insert into member (city,street,zipcode,name,member_id) values (NULL,NULL,NULL,'kim',1); 2024-06-20T21:12:05.345+09:00 INFO 21664 --- [ Test worker] p6spy : #1718885525345 | took 0ms | commit | connection 3| url jdbc:h2:mem:7cd22d26-ead4-4150-987b-79b62bd18ed5 ; 혼자 해결을 하고 싶었는데 가망이 없어 질문 올립니다.. 부탁드립니다!! ㅠㅠㅠㅠㅠ https://drive.google.com/file/d/1k4Dsk8P3O2Ofm0Ab-CyVTA98aN-66p1_/view?usp=drive_link

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

강사님의 형변환결과값이랑 저의 형변환결과값이 다른경우...ㅠㅠ

미해결

김영한의 자바 입문 - 코드로 시작하는 자바 첫걸음

=========================================[질문 내용] public class Casting3 { public static void main(String[] args) { long maxIntValue= 2147483647; //int 최고값 long maxIntOver= 21474836478L; //int 최고값 + 1(초과) int intValue=0; intValue = (int) maxIntValue; // 형변환 System.out.println("maxValue Casting= "+ intValue); intValue = (int) maxIntOver; //형변환 System.out.println("maxIntOver Casting = " + intValue); } } 근데 저의 결과값은 ..... 이렇게 나오는 이유가 있을까요?

  • java
  • 객체지향
  • 형변환
YEDEV 댓글 1 좋아요 0 조회수 262

상속관계 Joined - 임시 테이블로 생성/삭제로 인한 성능 문제

미해결

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

안녕하세요 영한님. 상속관계 Joined 매핑을 사용할 때, 부모테이블에 대하여 업데이트 쿼리 시 임시 테이블 Create Drop 에 대해 질문드리고 싶습니다. 최근에 플젝을 진행하면서 JPA 상속관계 Joined 전략을 활용했는데요, 프로젝트 초기에는 정규화된 테이블 구조로 먼저 진행하고, 추후 성능 이슈가 발생하면 단일 테이블 전략으로 역 정규화를 논의하는 것이 나을 것으로 판단했기 때문입니다. Domain // 부모 엔티티 @Entity @DiscriminatorColumn @Inheritance(strategy = InheritanceType.JOINED) public class Notification { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "notification_id") private Long id; @Enumerated(value = EnumType.STRING) @Column(nullable = false, columnDefinition = "varchar(50)") private NotificationEventType notificationEventType; @Column(nullable = false) private LocalDateTime createdAt; @Column(name = "\"read\"", nullable = false) private Boolean read; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id", nullable = false) private User notifier; } // 자식 엔티티 @Entity public class RecruitmentNotification extends Notification { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "recruitment_id", nullable = false) private Recruitment actor; } @Entity public class StudyNotification extends Notification { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "study_id", nullable = false) private Study actor; } @Entity public class ReviewNotification extends Notification { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "review_id", nullable = false) private Review actor; } Service @Service @RequiredArgsConstructor @Slf4j public class NotificationCommandService { private final NotificationRepositoryImpl notificationRepository; public void updateNotificationsAsRead(final User user, final List<Long> notificationIds) { notificationRepository.updateNotificationsAsRead(user.getId(), notificationIds); } } Repository public interface NotificationJpaRepository extends JpaRepository<Notification, Long> { @Modifying @Query("UPDATE Notification n " + "SET n.read = true " + "WHERE n.notifier.id = :userId AND n.id IN :notificationIds") void updateNotificationsAsRead(final Long userId, final List<Long> notificationIds); } @Repository @RequiredArgsConstructor public class NotificationRepositoryImpl { private final JPAQueryFactory q; private final NotificationJpaRepository notificationJpaRepository; private final EntityManager em; public void updateNotificationsAsRead(final Long userId, final List<Long> notificationIds) { notificationJpaRepository.updateNotificationsAsRead(userId, notificationIds); em.flush(); em.clear(); } } 부모테이블에 대하여 업데이트 쿼리 시, JPA 구현체가 자체적으로 임시 테이블을 Create 및 Drop 하는 로그를 확인했습니다. create temporary table if not exists HT_notification(notification_id bigint not null, primary key (notification_id)) drop temporary table HT_notification 두 가지 문제점이 있다고 생각하는데요. 보안 이슈 등을 고려하여, 현재 상용 DB 의 백엔드 사용자 권한에 DDL을 제외하였습니다. 이에 따라 임시 테이블을 생성하지 못하고, 500 에러가 발생하는 상황입니다. JPA 상속 관계 매핑 전략만을 위해 DB 사용자 권한을 넓게 가져가는 것이 올바른지 잘 모르겠습니다 🤔 업데이트 API를 호출할 때마다, 임시 테이블을 생성하고 드랍하는 행위가 매우 비효율적 이라 생각되는데, 이럴 경우 Single 테이블 전략으로 수정하거나, 상속관계 매핑 자체를 안쓰는 방법밖엔 없을까요? 상속관계 매핑 전략은 애플리케이션 레벨에서 DB 테이블의 조작을 손쉽게하는 장점이 있긴하지만,결국 상용 서비스 중인 DB를 세팅할 땐 데이터베이스 레벨에서 DDL을 직접 세팅하는게 좋고, 기존의 장점이 상쇄되는 느낌입니다. 성능적 손해를 감수하면서도 상속 관계 매핑을 활용하는게 좋은 접근 방법인지 판단이 서지 않아 질문드립니다 🙂

  • java
  • jpa
김준기 댓글 1 좋아요 0 조회수 212

상속관계 Joined 매핑 - 임시 테이블 Create Drop에 관하여

미해결

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

안녕하세요 영한님. 상속관계 Joined 매핑을 사용할 때, 부모테이블에 대하여 업데이트 쿼리 시 임시 테이블 Create Drop 에 대해 질문드리고 싶습니다. 최근에 플젝을 진행하면서 JPA 상속관계 Joined 전략을 활용했습니다. 부모테이블에 대하여 업데이트 쿼리 시, JPA 구현체가 자체적으로 임시 테이블을 Create 및 Drop 하는 로그를 확인했습니다. Domain // 부모 엔티티 @Entity @DiscriminatorColumn @Inheritance(strategy = InheritanceType.JOINED) public class Notification { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "notification_id") private Long id; @Enumerated(value = EnumType.STRING) @Column(nullable = false, columnDefinition = "varchar(50)") private NotificationEventType notificationEventType; @Column(nullable = false) private LocalDateTime createdAt; @Column(name = "\"read\"", nullable = false) private Boolean read; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id", nullable = false) private User notifier; } // 자식 엔티티 @Entity public class RecruitmentNotification extends Notification { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "recruitment_id", nullable = false) private Recruitment actor; } @Entity public class StudyNotification extends Notification { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "study_id", nullable = false) private Study actor; } @Entity public class ReviewNotification extends Notification { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "review_id", nullable = false) private Review actor; } Service @Service @RequiredArgsConstructor @Slf4j public class NotificationCommandService { private final NotificationRepositoryImpl notificationRepository; public void updateNotificationsAsRead(final User user, final List<Long> notificationIds) { notificationRepository.updateNotificationsAsRead(user.getId(), notificationIds); } } Repository public interface NotificationJpaRepository extends JpaRepository<Notification, Long> { @Modifying @Query("UPDATE Notification n " + "SET n.read = true " + "WHERE n.notifier.id = :userId AND n.id IN :notificationIds") void updateNotificationsAsRead(final Long userId, final List<Long> notificationIds); } @Repository @RequiredArgsConstructor public class NotificationRepositoryImpl { private final JPAQueryFactory q; private final NotificationJpaRepository notificationJpaRepository; private final EntityManager em; public void updateNotificationsAsRead(final Long userId, final List<Long> notificationIds) { notificationJpaRepository.updateNotificationsAsRead(userId, notificationIds); em.flush(); em.clear(); } } 업데이트 API를 호출할 때마다, 임시 테이블을 생성하고 드랍하는 행위가 매우 비효율적 이라 생각되는데, 이럴 경우 Single 테이블 전략으로 수정하거나, 상속관계 매핑 자체를 안쓰는 방법밖엔 없을까요? 상속관계 매핑 전략은 애플리케이션 레벨에서 DB 테이블의 조작을 손쉽게하는 장점이 있긴하지만, 결국 상용 서비스 중인 DB를 세팅할 땐 데이터베이스 레벨에서 DDL을 직접 세팅하는게 좋고, 기존의 장점이 상쇄되는 느낌입니다. 성능적 손해를 감수하면서도 상속 관계 매핑을 활용하는게 좋은 접근 방법인지 판단이 서지 않아 질문드립니다 🙂

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

Id 대신 name을 사용하는 이유

해결됨

자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]

강의에서 사용자는 Id로 조회하고, 도서는 name으로 조회하는데 별도의 이유가 있을까요? 실제 구현한다면 동일한 도서명이 있을 것 같기도 하고, 일관성을 위해 강의를 참고하며 개인적으로 두가지 다 Id로 조회하도록 구현하고 있었습니다. Dto나 Repository 등에서 타입과 이름만 잘 변경해주면 문제가 없을꺼라고 생각했는데 중간에 제가 잘못 설계한 곳이 있는지 도서 대출시 BookRequestLoan에 값이 계속 안넘어옵니다. 혹시 Id (long 타입)로 조회하면 크게 달라지는 코드가 있거나 주의해야하는 부분이 있는지 여쭤보고 싶어서 문의글 남깁니다.

  • java
  • spring
  • aws
  • mysql
  • spring-boot
  • jpa
title.jjk 댓글 1 좋아요 0 조회수 145

여러 서버에서 db 접근 시 동시성문제

미해결

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

[질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예) [질문 내용] 여러 서버에서 db에 접근할 경우 sequence전략의 인덱스 처리가 궁금합니다. allocationsize를 50으로 설정한 경우 a 서버에서 1~50까지 확보, 다음 인덱스번호 51번 (a서버에서 아직 종료되지 않음) b 서버에서 인덱스번호 요청 51번 반환, 51~100번 인덱스 사용 만약 해당 상황의 a서버에서 데이터를 3개 추가한 후 종료된다면 1,2,3번 인덱스만 사용되고 4~50번 인덱스는 앞으로 사용되지 않는건가요?? 그리고 여러 서버를 작동시키고 이러한 방식으로 사용한다면 중간중간 비어있는 인덱스가 많아질 것인데, 비어있는 인덱스는 재활용이 불가능한지 궁금합니다.

  • java
  • jpa
ho_0214 댓글 1 좋아요 0 조회수 265

JpashopApplication.main()' 에러

미해결

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

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예) [질문 내용] 메인 메서드 실행은 되는데 종료할때 아래와 같은 에러가 납니다. 찾아봐도 해결이 안되네요 도움 부탁드립니다 참고용으로 Build.gradle 소스도 함께 올립니다. plugins { id 'java' id 'org.springframework.boot' version '3.3.0' id 'io.spring.dependency-management' version '1.1.5' } group = 'jpabook' version = '0.0.1-SNAPSHOT' java { toolchain { languageVersion = JavaLanguageVersion.of(17) } } configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' // Validation (JSR-303 validation with Hibernate validator) 모듈을 꼭! 추가 implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'org.springframework.boot:spring-boot-devtools'// compileOnly 'org.projectlombok:lombok' runtimeOnly 'com.h2database:h2' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' //JUnit4 추가 testImplementation("org.junit.vintage:junit-vintage-engine") { exclude group: "org.hamcrest", module: "hamcrest-core" } testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } tasks.named('test') { useJUnitPlatform() }

  • java
  • spring
  • 웹앱
  • spring-boot
  • jpa
현이 댓글 2 좋아요 0 조회수 198

질문있습니다

해결됨

김영한의 실전 자바 - 기본편

public class BabyDog extends Dog{ @Override public void sound() { System.out.println("낑낑"); } } BabyDog라는 클래스를 만들고 Dog를 상속받았을경우 메인클래스에서 soundAnimal(dog)를했을때 제가생각하는 이미지는 sound() Animal sound() Dog sound() BabyDog 이렇게돼서 결국 맨아래 BabyDog sound가불려서 낑낑이나올거같은데 멍멍이나오더라구요 어떤점을 잘못이해한건지 알려주실수있을까요?

  • java
  • 객체지향
Choi 댓글 1 좋아요 1 조회수 231

"비밀번호" 문제 확인 부탁드립니다!

미해결

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

안녕하세요! 비밀번호 문제를 다음과 같이 풀었는데 확인 한번 부탁드려도될까요~? class Solution { public int solution(int[] keypad, String password) { int answer = 0; char[] pw = password.toCharArray(); int[] index = new int[pw.length]; for (int i = 0; i < 9; i++) { for (int j = 0; j < pw.length; j++) { if (pw[j] - '0' == keypad[i]) { index[j] = i; } } } for (int i = 0; i < index.length - 1; i++) { int curr = index[i]; if (curr == index[i + 1]) { continue; } if (curr % 3 == 0) { // left if (index[i + 1] - curr == -3 || index[i + 1] - curr == -2 || index[i + 1] - curr == 1 || index[i + 1] - curr == 3 || index[i + 1] - curr == 4) { answer++; } else { answer += 2; } } else if (curr % 3 == 1) { // center if (index[i + 1] - curr >= -4 && index[i + 1] - curr <= 4) { answer++; } else { answer += 2; } } else if (curr % 3 == 2) { // right if (index[i + 1] - curr == -4 || index[i + 1] - curr == -3 || index[i + 1] - curr == -1 || index[i + 1] - curr == 2 || index[i + 1] - curr == 3) { answer++; } else { answer += 2; } } } return answer; } public static void main(String[] args) { Solution T = new Solution(); System.out.println(T.solution(new int[]{2, 5, 3, 7, 1, 6, 4, 9, 8}, "7596218")); System.out.println(T.solution(new int[]{1, 5, 7, 3, 2, 8, 9, 4, 6}, "63855526592")); System.out.println(T.solution(new int[]{2, 9, 3, 7, 8, 6, 4, 5, 1}, "323254677")); System.out.println(T.solution(new int[]{1, 6, 7, 3, 8, 9, 4, 5, 2}, "3337772122")); } } 0 1 2 3 4 5 6 7 8 패스워드의 각 문자에 대해 인덱스 번호를 구한 뒤 왼쪽, 가운데, 오른쪽임에 따라 다음 값과의 차이를 비교하여 +1인지 +2인지 구분하는 형태로 코드를 작성해봤습니다. 강사님이 풀이해주신 방식과는 다소 차이가 있어보여서 어떤 방식이 괜찮은지 혹은 위 방식에 문제점이 있는지 궁금하여 질문 올려봅니다

  • java
  • 코딩-테스트
주노 댓글 1 좋아요 0 조회수 193

인텔리제이에서 경고 표시가 수업 화면과 다르게 나오는 현상

미해결

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

실제로 코드를 치면 이렇게 형광펜처럼 경고 표시가 나오는데 강의 화면에서는 밑줄로만 표시되어서요! 혹시 설정을 따로 진행하신걸까요? ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 여기에 질문 내용을 남겨주세요.

  • java
  • 객체지향
맥스 댓글 1 좋아요 0 조회수 234

RestController와 view 관련하여 질문있습니다.

미해결

안녕하세요. 개인 프로젝트를 진행하다 이해가 안되는 부분이 있어서 질문드립니다. 맛집 서비스를 위한 REST API (HTTPS)를 구성하는 프로젝트로, 맛집 정보들은 DB를 사용하여 관리 REST API는 CRUD 연산을 제공 할 것입니다. 일단 프론트단을 제외하고 백만 개발한거라 @RestController를 사용해서 테스트를 끝냈는데, 이제 프론트까지 개발하려고 하니 @RestController는 json 형식으로 데이터를 받잖아요. 화면을 생성해야하는데 @RestController와 별개로 새로운 클래스를 생성하여 @Controller를 붙여 뷰단만 따로 관리하는 컨트롤러를 생성하는게 좋을까요? @RestController는 REST API를 관리하는 컨트롤러, @Controller는 화면단만 관리하는 컨트롤러로 각각 생성하는게 좋은건지 아니면 개발했던 @RestController에 ModelAndView를 활용하는 것 중 뭐가 더 나은건지? 궁금해요. 찾아보니 RestController에 화면을 줄때 자바스크립트나 ajax를 사용하는 방법이 있긴한데 보통 뭐를 더 사용하고 뭐가 더 좋은지 궁금합니다.

  • springboot
  • java
  • restcontroller
  • controller
고구마 댓글 3 좋아요 0 조회수 382

기본값 타입에 식별자도 포함되는지

해결됨

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

JPA에서는 데이터 타입을 톱레벨에서 2가지, 엔티티 타입과 값 타입으로 분류한다고 하는데 식별자도 값 타입 중 기본값 타입으로 분류되는 것이 맞나요? 예를 들어 Member 엔티티에 식별자인 memberId와 필드인 name, age가 있다면 memberId, name, age 모두 기본값 타입인 것인지 궁급합니다. 당연한 질문일 수도 있겠지만, 설명하실 때와 강의자료에서 모두 식별자가 기본값 타입이라는 언급을 안하시는 것 같아서 예외적인 부분인가 하여 질문합니다.

  • java
  • jpa
WOOKI 댓글 1 좋아요 0 조회수 195

dslContext 작성 시 fetchGroups 이렇게 작성해도 될까요?

해결됨

실전 jOOQ! Type Safe SQL with Java

fun findActorFilmography(searchOption: ActorFilmographySearchOption): List<ActorFilmography> { val actorListMap = dslContext.select( ACTOR, FILM, ).from(ACTOR) .join(FILM_ACTOR).on(ACTOR.ACTOR_ID.eq(FILM_ACTOR.ACTOR_ID)) .join(FILM).on(FILM.FILM_ID.eq(FILM_ACTOR.FILM_ID)) .where( containsIfNotBlank(ACTOR.FIRST_NAME.concat(" ").concat(ACTOR.LAST_NAME), searchOption.actorName), containsIfNotBlank(FILM.TITLE, searchOption.filmTitle), ) // 이 부분!! .fetchGroups( { record -> record[ACTOR.name, Actor::class.java] }, { record -> record[FILM.name, Film::class.java] } ) return actorListMap.entries .map { entry -> ActorFilmography(entry.key, entry.value) } } private fun containsIfNotBlank(field: Field<String?>, inputValue: String?): Condition { if (inputValue.isNullOrBlank()) { return DSL.noCondition() } return field.likeRegex(inputValue) } alias을 사용하지 않고, name으로 추출해봤더니 데이터가 정상적으로 잘 나와서요!! 혹시나 예외 케이스도 있을 수 있을 것 같아 질문합니다!

  • java
  • sql
  • spring-boot
  • jooq
  • dsl
chhong 댓글 6 좋아요 2 조회수 697

44강) grep으로 임시 비밀번호가 안뜨는 경우

미해결

자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]

sudo cat /var/log/mysqld.log | grep "temporary password” 이걸로 수정해서 진행해보세요! 출처) https://www.fedoralinux.or.kr/forums/topic/21405

  • java
  • spring
  • aws
  • mysql
  • spring-boot
  • jpa
학습중입니다 댓글 2 좋아요 0 조회수 180

서버간의 인증에 Oauth활용

미해결

스프링 시큐리티 OAuth2

안녕하세요...! 클라이언트단에서 로그인을 통한 OAuth가 아닌 서버간의 통신에 인증을 위해 OAuth를 활용하고 싶은데 이때에는 그럼 WAS01(클라이언트1, 리소스서버1) , WAS02(리소스서버2) , 인가서버로 구성해서 클라이언트1이 인가서버로 토큰 요청 클라이언트1이 받은 access token을 셋팅해서 RestTemplate을 통해 WAS02의 특정 api 호출 WAS02에서 클라이언트 자격 증명 WAS01로 응답 제공 => 이렇게 해야하는건가 구성을 생각하고 있는데, 한대의 서버에 클라이언트와 리소스서버를 같이두고 이렇게 구성하는게 맞는 방향일까요? 그리고 인가서버를 꼭 다른 포트로 띄워야하는지도 궁금합니다...!

  • java
  • spring
  • spring-boot
  • oauth
kanghyojung 댓글 1 좋아요 0 조회수 412

update with dto 질문

해결됨

실전 jOOQ! Type Safe SQL with Java

안녕하세요 강사님 update, delete를 통한 데이터 수정, 삭제 강의를 듣는 도중 이상한 점이 있는것 같아 질문드립니다. update with dao 설명 중 var firstname과 var lastname의 반환값이 Filed<String>이 된다는 설명(약 7분정도)을 해주셨고 값이 없을때는 무시가 된다고 하셨는데, 7분 33초쯤에 로그를 아래 제가 첨부한 사진과 같이 나옵니다. last_name이 TTTTT로 되어있습니다. 편집상의 오류인지 로그 출력이 왜 저런지 의문이 들어 질문드립니다.

  • java
  • sql
  • spring-boot
  • jooq
  • dsl
sw 댓글 1 좋아요 1 조회수 283

인기 태그

인프런 TOP Writers

주간 인기글