묻고 답해요
161만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨나도코딩의 자바 기본편 - 풀코스 (20시간)
상대경로 관련 질문드립니다
안녕하세요! 퀴즈를 풀다가 상대 경로에 대해 궁금한 점이 생겨 질문드립니다.강의에서 saying.txt 파일과 Quiz_13 파일이 chap_13에 속한 상황으로 나옵니다. 여기서 저는 상대 경로는 현재 디렉토리를 기준으로 목표로 하는 파일의 위치를 작성하는 것이라고 이해하여 FileReader의 파라미터로 "saying.txt"라고 작성하였습니다. 그런데 강의를 본 후 src폴더의 경로부터 작성해야 함을 알게 되었습니다. ("src/chap_13/saying.txt")분명 saying.txt 파일과 Quiz_13 파일이 같은 chap_13 폴더에 있는데 왜 상위 폴더인 src 폴더의 경로부터 작성하는건가요?
-
미해결스프링 시큐리티 OAuth2
임시 코드 요청시 Redirect에 대해 질문 드립니다
client registration의 redirect uri는 인가 서버로부터 임시코드를 발급받고, redirect uri로 임시 코드를 리다이렉트 시키는데,강사님께서redirect uri를 http://localhost:8081/client 로 설정하였고,ClientController의 매핑주소도 위와 같은 주소로 설정하였습니다. 여기서 궁금한점이 있습니다. 임시 코드를 발급한 시점에 저 리다이렉트 주소로 콜백하게 되는데, 이 시점에 clientcontroller에 저 매핑주소가 호출되어야 할텐데왜 token 발급시에 컨트롤러가 호출되는지그리고 redirect uri가 token 발급시 콜백 주소도 해당되는건가요?? 엑세스 토큰 발급후에도 http://localhost:8081/client여기로 호출되어서 의문이 듭니다.
-
미해결윤재성의 만들면서 배우는 Spring MVC 5
8강 에서 servlet-context.xml에 설정에서 에라
servelt-context.xml에서 <annotation-driven/>를 입력하면 그림과 같은 에라가 나오는데 어떻게 해야 하나요 ?
-
미해결실전! 코틀린과 스프링 부트로 도서관리 애플리케이션 개발하기 (Java 프로젝트 리팩토링)
Book.kt 추가후 에러
태현님 안녕하세요!저도 같은 에러가 발생했는데 (질문 게시판에 같은 질문이 있는데... 링크를 얻기가 어렵네요)build.gradle 에implementation 'org.jetbrains.kotlin:kotlin-reflect:1.2.41'을 추가하니까 해결 되었습니다..! 혹시 원인을 알 수 있을까요?현재까지 공부한 프로젝트를 보내고 싶은데... 메일로 보낼수 있을까요? 파일 첨부가 안되네용
-
미해결재고시스템으로 알아보는 동시성이슈 해결방법
테스트 코드에서 매번 1번 유지
테스트 코드에서 매번 stock id 1번으로 조회하는데 이게 어떻게 가능한건가요?저의 경우 1번 객체가 없어서 에러를 처리합니다.
-
해결됨[자바/Java] 문과생도 이해하는 DFS 알고리즘! - 입문편
code의 어디가 잘못된지 도저히 모르겠습니다..
안녕하세요. 해당 문제의 코드를 다음과 같이 짰는데, 출력하면 항상 0이 출력됩니다.강의에 나온 부분과 거의 동일한데, 어느 부분에서 오류가 발생하는지 잘 모르겠습니다. 감사합니다.import java.util.*; import java.io.*; class Main { final static int MAX = 50 + 10; static boolean[][] map; static boolean[][] visited; static int W, H; static int[] DirY = {-1, -1, -1, 0, 0, 1, 1, 1}; static int[] DirX = {-1, 0, 1, -1, 1, -1, 0, 1}; public static void dfs(int y, int x) { visited[y][x] = true; for(int i = 0; i < 8; i++) { int newY = y + DirY[i]; int newX = x + DirX[i]; if(map[newY][newX] && visited[newY][newX] == false) { dfs(newY, newX); } } } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); // 0. 입출력 while(true) { StringTokenizer st; st = new StringTokenizer(br.readLine()); W = Integer.parseInt(st.nextToken()); H = Integer.parseInt(st.nextToken()); // 마지막 입력 값이 0이면 while 문 빠져나오기 if(W == 0 && H == 0) break; map = new boolean[MAX][MAX]; visited = new boolean[MAX][MAX]; for(int i = 1; i <= H; i++) { st = new StringTokenizer(br.readLine()); for(int j = 1; j <= W; j++) { map[i][j] = (Integer.parseInt(st.nextToken()) == '1') ? true : false; } } int answer = 0; for(int i = 1; i <=H; i++) { for(int j = 1; j <=W; j++) { if(map[i][j] && visited[i][j] == false) { dfs(i, j); answer++; } } } bw.write(String.valueOf(answer)); bw.newLine(); } bw.close(); br.close(); } }
-
해결됨실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
밑의 질문과 같이 테스트는 통과 했으나 테이블이 안생깁니다...
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? 예2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? 있으나 해결이 안됨3. 질문 잘하기 메뉴얼을 읽어보셨나요? 예[질문 내용]안녕하세요 실전 스프링부트+jpa1 의 jpa와 db 설정, 동작확인을 듣고있는 학생입니다. 밑의 질문과 같은 이유로 질문하게 되었는데요. application.yml의 들여쓰기가 문제일까 싶어서 들여쓰기를 들였는데 그럼에도 생성이안됩니다... 어디가 문제일까요?? 그리고 그... localhost:8082를 접속할때 접속이 될때가 있고 안될때가 있는데 이유가 뭘까요?? Iterm으로 ./h2-sh로 킨 상태를 계속 유지해야 콘솔에 접근할 수 있는건가요?
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
스프링 통합테스트 코드를 따라치고 있습니다. h2 db에 이름이 중복되어있을텐데 오류가 안납니다.
질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용] 영한님 말씀대로면 이름이 같을시 오류가 떠야되는데 저는 뜨질 않고 돌아갑니다. 왜그런가요?@Transactional 주석처리하고 해도 같은결과입니다.
-
미해결나도코딩의 자바 기본편 - 풀코스 (20시간)
intellij 라아센스
intellij에서 라이센스 선택하는 게 나오는 데 어떤것을 선택해야하나요? 그냥 나가기 누르면 창이 꺼집니다. start trial로 하면 될까요?
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
h2 데이터베이스 설정 질문
여기에 질문 내용을 남겨주세요.1:09 에서 bin에서 ./h2.sh 했는데 denied 당했습니다.. 이거 어떻게 해결해야 할까요??
-
해결됨실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
cannot find declaration to go to 오류
강의 내용 중 hello를 눌렀을때(단축키 사용 ctrl+b) cannot find declaration to go to 오류가 발생하더라고요. 구글이나 인프런 답변 내용들을 찾아서 제시해주신 해결 책으로 했을 때 해결이 안되어서 문의를 드립니다.src -> Mark Directory as -> Sources Root(해결x)file -> invalidate Caches -> Restart(해결x)혹시 무료버전을 사용하고 있어서 해결이 안되는걸까요??
-
미해결자바 ORM 표준 JPA 프로그래밍 - 기본편
No Persistence provider for EntityManager named hello ? 오류
실행하면 저렇게 오류가 발생해요 ㅠㅠ <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"> <persistence-unit name="hello"> <properties> <!-- 필수 속성 --> <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/> <property name="javax.persistence.jdbc.user" value="sa"/> <property name="javax.persistence.jdbc.password" value=""/> <property name="javax.persistence.jdbc.url" value="jdbc:h2:tcp://localhost/~/test"/> <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/> <!-- 옵션 --> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.format_sql" value="true"/> <property name="hibernate.use_sql_comments" value="true"/> <!--<property name="hibernate.hbm2ddl.auto" value="create" />--> </properties> </persistence-unit> </persistence>이건 persistence.xml 이고 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>jpa-basic</groupId> <artifactId>ex1-hello-jpa</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <!-- JPA 하이버네이트 --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>5.6.15.Final</version> </dependency> <!-- h2 데이터베이스 --> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1.4.200</version> </dependency> <!-- Java 9 이상을 지원하는 JAXB API 라이브러리 --> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.1</version> </dependency> </dependencies> </project>이건 pom.xml 입니다 뭐가 틀린건가요? ㅠㅠ...
-
해결됨실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
Mybatis만 사용하는 경우의 Data Class 구조에 조언 구합니다.
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예 - 부분적인 관련이긴 합니다ㅜ)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]JPA를 사용하는 경우 Entity와 request/response(DTO)를 구분하는 부분은 충분히 공감하였습니다.그러면 혹시 Mybatis만을 활용하여 SQL로 바로 접근하는 프로젝트의 경우도 JPA와 같이 DB 계층(Entity/Repository)과 그 외 계층(DTO - Controller/Service)을 구분하여 Data Class를 설계하는 것이 필요할까요?현재 프로젝트는 Mybatis만을 사용하고 있으며 각 요청과 응답에 대해서는 request와 response DTO를 각각 생성하여 사용하고 있는 상황입니다.강의를 듣다보니 여기에 추가적으로 DB 계층으로 접근할 때의 Data Class를 추가하여 접근하는 것이 필요하지 않을까 해서 질문 드리게 되었습니다. 강의 내용과 조금 거리가 있을 수 있으나 궁금함이 생겨 간단한 의견이라도 부탁 드립니다.
-
미해결즐거운 자바
Iterator<User> 대신에 Collections.unmodifiableList(users)를 사용해도 되나요?
[미니프로젝트] 회원관리 프로그램 강의 중에서 List<User> 객체가 외부에 의해서 값이 변경되는 것을 막기 위해 read only인 Iterator를 사용하셨는데요. 구글에서 검색해보니 다른 방법도 있는 것 같아요. Collections.unmodifiableList(List list) 를 사용하면 immutable (read-only)로 List를 return 할 수 있다고 하네요. https://softwareengineering.stackexchange.com/questions/316234/how-to-design-an-iterable-but-immutable-read-only-collection
-
미해결스프링 기반 REST API 개발
섹션2 201응답받기 부분 테스트 404에러 질문입니다
위, 아래의 사진은 수업에서 진행한 EventConroller, EventControllerTests의 전문입니다.테스트하면 아래의 에러메세지가 나옵니다 수업과 같이 진행했는데 왜 발생하는지를 모르겠습니다 도와주세요Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appendedMockHttpServletRequest: HTTP Method = POST Request URI = /api/events/ Parameters = {} Headers = [Content-Type:"application/json;charset=UTF-8", Accept:"application/hal+json"] Body = null Session Attrs = {}Handler: Type = org.springframework.web.servlet.resource.ResourceHttpRequestHandlerAsync: Async started = false Async result = nullResolved Exception: Type = nullModelAndView: View name = null View = null Model = nullFlashMap: Attributes = nullMockHttpServletResponse: Status = 404 Error message = null Headers = [Vary:"Origin", "Access-Control-Request-Method", "Access-Control-Request-Headers"] Content type = null Body = Forwarded URL = null Redirected URL = null Cookies = []java.lang.AssertionError: Status Expected :201Actual :404<Click to see difference> at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:59) at org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:122) at org.springframework.test.web.servlet.result.StatusResultMatchers.lambda$matcher$9(StatusResultMatchers.java:637) at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:214) at me.gang.demorestapi.events.EventControllerTests.createEvent(EventControllerTests.java:31) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:76) at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
-
미해결자바(Java) 알고리즘 문제풀이 입문: 코딩테스트 대비
쇠막대기 오답 질문
닫는 괄호를 만날 때마다 count++를 해주는 방식은 왜 정답이 안나오는 지 알 수 있을까요?import java.util.Scanner; import java.util.Stack; public class Main { public static int solution(String str){ int answer = 0; char[] strTochars = str.toCharArray(); Stack<Character> stack = new Stack<>(); int count = 0; for (int i=0; i<strTochars.length; i++) { if (strTochars[i] == '(') stack.push('('); else { if (!stack.isEmpty() && stack.peek() == '(') { stack.pop(); count ++; if (i>0 && strTochars[i-1] != '(') { // 막대 answer += count; count = 0; } } } } return answer; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.nextLine(); System.out.println(solution(str)); } }
-
미해결자바(Java) 알고리즘 문제풀이 입문: 코딩테스트 대비
문장속단어 강의에서 질문
String의 문장속단어 강의에서"int m = Integer.MIN_VALUE, pos;" 이부분이요. m이라는 변수에 Integer.MIN_VALUE이라는 상수값을 초기화하고,pos라는 변수는 선언만 한건가요? 풀어서 쓰면, "int m = Integer.MIN_VALUE; int pos;" 이거를 한 줄로 나타낸건가요???
-
미해결자바 ORM 표준 JPA 프로그래밍 - 기본편
1:1 연관관계
1:1 연관관계인 두 엔티티가 존재할 경우, 사실 1개의 테이블로 관리할 수 있고, 2개의 테이블 분리해서 관리할 수 있는데, 두 엔티티를 분리하는게 더 나을 것 같아서 2개의 엔티티로 분리하는 걸까요?
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
등록오류 및 조회 오류
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)예2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)예3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)예[질문 내용]여기에 질문 내용을 남겨주세요.자꾸 등록할때마다 이렇게 오류뜨고 h2db에선 member테이블이 있습니다. https://drive.google.com/file/d/15hAqagzQ4Yg-4Vqn2rnE_byFxQIsM8CC/view?usp=drive_link
-
해결됨자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]
안녕하세요. 강의 후 개인적으로 학습 시 나타나는 NPE관련 질문드립니다.
안녕하세요! 강의를 완강 후 혼자 프로젝트를 진행하다 도서 대출 코드를 보고 비슷하게 구현한 사용자가 채용공고를 지원하는 메소드를 호출시 테스트 코드에서 NPE가 발생하는데 혹시 이유를 알 수 있을까요? 여러가지 서칭해봐도 해결이 안되서 질문드립니다... ㅠㅠ회원entity@Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Table(name = "users") @Entity public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "user_id") private Long id; private String name; @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true) private List<ApplyHistory> applyHistory = new ArrayList<>(); public void applyCompany(JobPosting jobPosting) { this.applyHistory.add(new ApplyHistory(this, jobPosting)); } @Builder private User(Long id, String name, List<ApplyHistory> applyHistory) { this.id = id; this.name = name; this.applyHistory = applyHistory; } }ApplyHistory entity(JobPosting과 user객체가 N:M 매핑해주는 entity)@Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Table(name = "apply_history") @Entity public class ApplyHistory { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "apply_history_id") private Long id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id") private User user; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "job_posting_id") private JobPosting jobPosting; public ApplyHistory(User user, JobPosting jobPosting) { this.user = user; this.jobPosting = jobPosting; } } JobPosting Entity@Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Table(name = "job_posting") @Entity public class JobPosting { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "job_posting_id") private Long id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "company_id") private Company company; @Column(name = "posting_position") private String position; private int compensation; //채용보상금 @Column(name = "posting_details") private String postingDetails; @Column(name = "technology_used") private String technologyUsed; @Builder private JobPosting(Company company, String position, int compensation, String postingDetails, String technologyUsed) { this.company = company; this.position = position; this.compensation = compensation; this.postingDetails = postingDetails; this.technologyUsed = technologyUsed; } public void updateJobPosting(String position, int compensation, String postingDetails, String technologyUsed) { this.position = position; this.compensation = compensation; this.postingDetails = postingDetails; this.technologyUsed = technologyUsed; } } applyService@RequiredArgsConstructor @Service public class ApplyService { private final JobPostingRepository jobPostingRepository; private final UserRepository userRepository; private final ApplyHistoryRepository userJobPostingRepository; @Transactional public void applyCompany(ApplyCompanyRequest request) { // 1. 채용공고 정보 찾기 JobPosting jobPosting = jobPostingRepository.findById(request.getJobPostingId()) .orElseThrow(() -> new ResourceNotFoundException("jobPosting", request.getJobPostingId())); // 2. 유저 정보 가져오기 User user = userRepository.findById(request.getUserId()) .orElseThrow(() -> new ResourceNotFoundException("user", request.getUserId())); // 3. 지원 유무 확인 // 3-1. 지원 중이면 예외 발생 if (userJobPostingRepository.existsByJobPostingAndUser(jobPosting, user)) { throw new IllegalArgumentException("이미 지원하신 회사입니다."); } user.applyCompany(jobPosting); } } 리퀘스트@Getter @Setter public class ApplyCompanyRequest { private Long jobPostingId; private Long userId; } 서비스 테스트 코드@SpringBootTest class ApplyServiceTest { @Autowired JobPostingService jobPostingService; @Autowired ApplyService applyService; @Autowired JobPostingRepository jobPostingRepository; @Autowired UserRepository userRepository; @Autowired ApplyHistoryRepository applyHistoryRepository; @Autowired CompanyRepository companyRepository; @AfterEach void tearDown() { applyHistoryRepository.deleteAllInBatch(); jobPostingRepository.deleteAllInBatch(); userRepository.deleteAllInBatch(); companyRepository.deleteAllInBatch(); } @DisplayName("사용자는 채용 공고를 지원 할 수 있다.") @Test @Transactional void applyCompany() { //given User user = User.builder() .id(1L) .name("jw") .build(); User savedUser = userRepository.save(user); Company company = Company.builder() .name("company1") .country(Country.KOREA) .city(City.SEOUL) .build(); Company savedCompany = companyRepository.save(company); JobPosting jobPosting = JobPosting.builder() .company(savedCompany) .position("백엔드") .postingDetails("백엔드 개발자 채용합니다.") .compensation(500000) .technologyUsed("Java") .build(); JobPosting savedJobPosting = jobPostingRepository.save(jobPosting); ApplyCompanyRequest request = new ApplyCompanyRequest(); request.setUserId(savedUser.getId()); request.setJobPostingId(savedJobPosting.getId()); //when applyService.applyCompany(request); //then } } -> 이부분에서 applyCompany(request) 호출 시 NPE가 발생합니다.java.lang.NullPointerException at com.wanted.findjob.domain.user.User.applyCompany(User.java:36) at com.wanted.findjob.api.service.ApplyService.applyCompany(ApplyService.java:39) at com.wanted.findjob.api.service.ApplyService$$FastClassBySpringCGLIB$$2f4064b0.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:792) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:707) at com.wanted.findjob.api.service.ApplyService$$EnhancerBySpringCGLIB$$81701d47.applyCompany(<generated>) at com.wanted.findjob.api.service.ApplyServiceTest.applyCompany(ApplyServiceTest.java:83) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725) at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84) at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55) 테스트코드가 아닌 직접 서버를 작동해서 api를 호출 시 정상적으로 db에 들어가는 걸 볼 수 있는데 어디가 문제 인지를 모르겠습니다.. ㅠ