inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

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

트랜잭션 서비스 계층에서의 문제

미해결

스프링 DB 2편 - 데이터 접근 활용 기술

트랜잭션을 리포지토리 말고 서비스 계층에 달면 문제가 생기네요ㅠㅠ org.springframework.dao.InvalidDataAccessApiUsageException: No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call; nested exception is javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call 서비스 계층서 클래스레벨에 트랜잭션 달고 실행시 이렇게 ..나오는데 레포지토리에달면 잘 동작하는데.. 서비스 계층에 달면 왜그런걸까요..

  • spring
  • mvc
  • jpa
  • querydsl
  • spring-data-mybatis
  • spring-jpa
플하 댓글 11 좋아요 0 조회수 911

회원가입-status 201 Ok- 리다이렉트 안되는 현상

미해결

Next + React Query로 SNS 서비스 만들기

일전에 동일한 문제로 질문 올렸는데, 혹시나 제 코드에 발견되지 않은 오타나 문제가 있을까하여 제로초님 깃에서 다운받은 ch4폴더로 실행해도 동일한 문제 발생합니다. MacOs: Ventura 13.6.4 크롬브라우저로 보고있습니다. DB연결문제는 Postgresql은 버전을 낮춰서 Homebrew로 설치하고, Username을 맥os 유저네임으로 변경하니까 다행히 연결이되었습니다. 그런데 여전히, 회원가입후 리다이렉트 안되는 현상과 심지어 회원가입 된 Postgresql 테이블에 User정보도 잘 들어가있고, 회원가입된 유저의 id,비번으로 로그인해도 로그인도 안됩니다. package.json 버전정보: 클라이언트에서 리턴받은 값: 서버에서 나오는 console: 무엇이 문제일까요?

  • react
  • next.js
  • react-query
  • next-auth
  • msw
라푼젤 댓글 5 좋아요 0 조회수 868

asyncio.run() cannot be called from a running event loop 에러 질문 드립니다

미해결

실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용

안녕하세요 선생님 강의 듣고 있는 이광희라고 합니다. 올려주신 강의로 텔레그램 자체 API를 써서 메세지 전송하기까진 했는데요 이미지를 전송하려고 보니 거의 모든 블로그, 유튜브 설명들이 파이썬 텔레그램봇으로 설명 하더라구요 근데 이 봇이 v20으로 바뀌면서 비동기 프로그래밍(?)이 된거 같습니다. 설명하고 있는 코드들이 다 과거 버전 코드들이네요. 그래서 위키에 직접 가서 코드를 보고 있는데요 import asyncio import telegram async def main(): bot = telegram.Bot("TOKEN") async with bot: print(await bot.get_me()) if __name__ == '__main__': asyncio.run(main()) 그냥 위키에 나오는 간단한 코드인데도 RuntimeError: asyncio.run() cannot be called from a running event loop 이런 에러가 계속 뜹니다. async 부터 공부하려고 다른 유튜브를 찾아서 import asyncio async def main(): await asyncio.sleep(1) print('hello') asyncio.run(main()) 이런 간단한 코드를 입력해도 똑같은 오류가 뜨네요... 이벤트 메인 루프가 실행되고 있는 동안에 함수가 작동할수 없다 그런 내용인거 같은데 위키에 있는 그대로 따라해도 에러가 나니 비전공자 입장에서는 어떻게 해야 좋을지 모르겠네요. 경영학과 출신 직장인이 실무에서 쓰려고 파이썬을 배우고 있는데 물어볼곳이 여기밖에 없어 여쭤봅니다ㅠㅠ 좀 도와주세요 깃헙? 말고 국내 파이썬 qna있는 커뮤니티라도 알려주시면 가서 좀 물어보고 싶은데 그게 어디인지도 모르겠네요.

  • python
  • 웹-크롤링
  • selenium
  • beautifulsoup
Kwanghee Lee 댓글 4 좋아요 0 조회수 3999

Create React App에서 Next.js로 마이그레이션하기 의 깃허브 소스도 npm i 하면 에러가 발생합니다.

해결됨

손에 익는 Next.js - 마이그레이션하기

Create React App에서 Next.js로 마이그레이션하기 의 깃허브 소스도 npm i 하면 에러가 발생합니다. $ npm install npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: react-scripts@5.0.1 npm ERR! Found: typescript@5.3.3 npm ERR! node_modules/typescript npm ERR! typescript@"^5.3.3" from the root project npm ERR! peer typescript@">= 2.7" from fork-ts-checker-webpack-plugin@6.5.3 npm ERR! node_modules/fork-ts-checker-webpack-plugin npm ERR! fork-ts-checker-webpack-plugin@"^6.5.0" from react-dev-utils@12.0.1 npm ERR! node_modules/react-dev-utils npm ERR! react-dev-utils@"^12.0.1" from react-scripts@5.0.1 npm ERR! node_modules/react-scripts npm ERR! react-scripts@"5.0.1" from the root project npm ERR! 1 more (tsutils) npm ERR! npm ERR! Could not resolve dependency: npm ERR! peerOptional typescript@"^3.2.1 || ^4" from react-scripts@5.0.1 npm ERR! node_modules/react-scripts npm ERR! react-scripts@"5.0.1" from the root project npm ERR! npm ERR! Conflicting peer dependency: typescript@4.9.5 npm ERR! node_modules/typescript npm ERR! peerOptional typescript@"^3.2.1 || ^4" from react-scripts@5.0.1 npm ERR! node_modules/react-scripts npm ERR! react-scripts@"5.0.1" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! npm ERR! For a full report see: npm ERR! C:\Users\Administrator\AppData\Local\npm-cache\_logs\2024-03-02T03_03_34_358Z-eresolve-report.txt 관련한 안내 좀 부탁합니다.

  • react
  • next.js
  • vitejs
억수 댓글 2 좋아요 0 조회수 426

Cannot find module 에러

해결됨

손에 익는 Next.js - 마이그레이션하기

vite 로 작성한 경우를 마이그레이션 하는데요. 강의에 따라서 진행하였는데 최종 아래처럼 에러가 발생합니다. Require stack: \node_modules\next\dist\server\dev\next-dev-server.js vite\node_modules\next\dist\server\dev\next-dev-server.js vite\node_modules\next\dist\server\next.js vite\node_modules\next\dist\server\lib\start-server.js package.json 은 아래와 같아요. { "name": "next-migration-02-vite", "private": true, "version": "0.0.0", "type": "module", "scripts": { "dev": "next dev", "build": "next build", "lint": "next lint", "start": "next start" }, "dependencies": { "next": "^14.1.1", "react": "^18.2.0", "react-dom": "^18.2.0" }, "devDependencies": { "@types/node": "20.11.24", "@types/react": "^18.2.56", "@types/react-dom": "^18.2.19", "@typescript-eslint/eslint-plugin": "^7.0.2", "@typescript-eslint/parser": "^7.0.2", "@vitejs/plugin-react": "^4.2.1", "eslint": "^8.56.0", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.5", "typescript": "^5.2.2", "vite": "^5.1.4" } } 관련해서 안내좀 부탁드립니다. 좋은 주말 되세요~

  • react
  • next.js
  • vitejs
억수 댓글 2 좋아요 0 조회수 909

결측값 채우지관련해서

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

안녕하십니까? 결측값 채우기 중 최빈값 관련해서,, m = X_train['workclass'].mode()[0] 여기서 mode()과 mode()[0]의 차이는 무엇인지요? 즉 [0]의 쓰임이 무엇인지? 다른 중앙값, 평균 등은 이런게 없는데 왜 최빈값만 이런게 뒤에 붙는지요?

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
kccjjang 댓글 2 좋아요 0 조회수 257

외래키 중복 관련 질문

미해결

스프링 DB 2편 - 데이터 접근 활용 기술

import com.example.banking.domain.user.User import com.example.banking.support.BaseEntity import jakarta.persistence.Entity import jakarta.persistence.FetchType import jakarta.persistence.JoinColumn import jakarta.persistence.ManyToOne @Entity class Account( var balance: Double, @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id") val user: User, id: Long = 0 ) : BaseEntity(id) { fun addAccount(user: User) { user.accounts.add(this) } fun addBalance(amount: Double) { balance += amount } fun subtractBalance(amount: Double) { balance -= amount } } import com.example.banking.domain.account.Account import com.example.banking.support.BaseEntity import jakarta.persistence.* @Entity class Transaction( val amount: Double, @Enumerated(EnumType.STRING) val type: TransactionType, @ManyToOne(fetch = FetchType.LAZY) @JoinColumn val sender: Account, @ManyToOne(fetch = FetchType.LAZY) @JoinColumn val recipient: Account?, id: Long = 0L ) : BaseEntity(id) { constructor(amount: Double, type: TransactionType, sender: Account) : this(amount, type, sender, null) } import com.example.banking.domain.account.Account import com.example.banking.domain.user.User import com.example.banking.domain.user.UserInfo import com.example.banking.repository.account.AccountRepository import com.example.banking.repository.transaction.TransactionRepository import com.example.banking.repository.user.UserRepository import jakarta.persistence.EntityManager import jakarta.transaction.Transactional import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.annotation.Rollback @SpringBootTest @Transactional @Rollback(value = false) class TransactionTest( @Autowired private val em: EntityManager, @Autowired private val transactionRepository: TransactionRepository, @Autowired private val userRepository: UserRepository, @Autowired private val accountRepository: AccountRepository ) { @Test fun testTransaction() { val user1 = User(UserInfo("b", "Seoul", "123", "123")) val user2 = User(UserInfo("b2", "Seoul", "123", "123")) userRepository.save(user1) userRepository.save(user2) em.flush() em.clear() val account1 = Account(100.0, user1) val account2 = Account(100.0, user2) account1.addAccount(user1) account2.addAccount(user2) accountRepository.save(account1) accountRepository.save(account2) em.flush() em.clear() val sender = accountRepository.findById(account1.id).get() val recipient = accountRepository.findById(account2.id).get() val transaction = Transaction(50.0, TransactionType.TRANSFER, sender, recipient) transactionRepository.save(transaction) em.flush() em.clear() val transaction2 = Transaction(50.0, TransactionType.DEPOSIT, sender) transactionRepository.save(transaction2) // assertThat(sender.balance).isEqualTo(50.0) // assertThat(recipient.balance).isEqualTo(150.0) } } 위와같이 Transaction 엔티티와 Account 엔티티가 ManyToOne 으로 매핑되었을때, 테스트코드를 위와같이 작성시, transactionRepository.save(transaction2) 이 라인에서 Duplicate entry '97' for key 'transaction.U K_96vb4d846be64bta5qbxiicb1' 에러가 발생합니다. 제가 알기론 외래키의 경우 중복된 값을 가지는것이 가능한것으로 알고 있는데, 같은 account id로 새로운 Transaction 을 생성할 시에 키가 중복이라는 에러가 발생하는데 왜 그런지 알고싶습니다. 코틀린으로 코드 작성한 점 양해부탁드립니다..

  • spring
  • mvc
  • jpa
  • querydsl
  • spring-data-mybatis
  • spring-jpa
댓글 1 좋아요 0 조회수 288

의존성 주입

미해결

스프링 DB 2편 - 데이터 접근 활용 기술

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 강의를 듣다가 순간 애매해서 질문드립니다. V2config에서 해당 코드를 @Bean public ItemService itemService() { return new ItemServiceV2(itemRepositoryV2, itemQueryRepositoryV2()); } @Bean public ItemQueryRepositoryV2 itemQueryRepositoryV2(){ return new ItemQueryRepositoryV2(em); } @Bean public ItemService itemService() { return new ItemServiceV2(itemRepositoryV2, new ItemQueryRepositoryV2(em)); } /** @Bean public ItemQueryRepositoryV2 itemQueryRepositoryV2(){ return new ItemQueryRepositoryV2(em); } **/ 처럼 ItemQueryRepositoryV2부분은 주석처리 해서 @Bean으로 등록을 하지 않으면 작동이 안돼야 할까요?? 변경하고 작동해봤는데 문제가 없어서 질문드립니다.

  • spring
  • mvc
  • jpa
  • querydsl
  • spring-data-mybatis
  • spring-jpa
sde101573 댓글 1 좋아요 0 조회수 377

선생님 혹시 SSV 파일을 json으로 변환할 방법이 있을까요?

미해결

파이썬으로 뭘 만들지? 남박사의 파이썬 알쓸파잡

안녕하세요. 선생님 수업을 통해 크롤링까지는 성공했습니다. HTTP POST 요청으로 받아왔는데요. 다만 Response가 넥사크로에서 사용하는 "SSV"형식으로 왔습니다. SSV:UTF-8ErrorCode:string=0ErrorMsg:string=Dataset:ds_PageList_RowType_TAXNO:string(255)TAXIDX:string(255)MEMBNAM:string(255)TSDATE:string(255)TSTIME:string(255)ACQBID:string(255)CARD_NAME:string(255)HID:string(255)ACQHID:string(255)TERMID:string(255)MTRCNO:string(255)CDNO:string(255)AUTHNO:string(255)ISTMMON:string(255)CURRCODE:string(255)AMT1:bigdecimal(25)AMT2:bigdecimal(25)AMT3:bigdecimal(25)ACQDATE:string(255)DDCEDI:string(255)...... <생략> 이렇게 못생긴 데이터가 왔는데요. 이걸 json으로 파싱하고싶어서요. 이리저리 혼자서 아스키코드 찾아보고 US, RS 사용해서 어떻게든 파싱은 했는데, 제가 짠 로직이 맞나 싶어서요. (일단 작동은 되는데.. ) 혹시 선생님이라면 어떻게 하실까 싶어서요. 이런걸 잘 파싱하려면 알고리즘을 공부해야되는걸까요? 아! 그리고 깃헙에 혹시 라이브러리가 있나 찾아봤는데요. 안나오더라구요. 이게 제일 슬펐어요. 그나저나 저런거 만드는 사람들은 정말 괴물같네요.. 저런걸 도대체 어떻게 만드는 걸까요? (코드가 본문에 저렇게 붙여넣어지는 기능도 신기하네요.. 저런건 또 어떻게 만드나요?)

  • python
  • 웹-크롤링
  • gui
포포 댓글 2 좋아요 0 조회수 848

simplejdbcinsert

미해결

스프링 DB 2편 - 데이터 접근 활용 기술

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] simplejdbcinsert를 여러 테이블에 적용해야 한다면 적용할 테이블 개수에 맞춰서 객체를 생성해줘야 할까요?

  • spring
  • mvc
  • jpa
  • querydsl
  • spring-data-mybatis
  • spring-jpa
sde101573 댓글 1 좋아요 0 조회수 306

DAY11 영상에 오타있네요

미해결

기초 알고리즘 코딩테스트 40일 완성 (by 하루코딩)

최댓값 문제 2566번인데 2556번(별 찍기 - 14)로 숫자가 잘못되어있습니다. 수정 부탁드립니다.

  • python
  • java
  • 코딩-테스트
kairs294702 댓글 2 좋아요 0 조회수 293

useQuery랑 queryClient.getQueryData랑 차이점이 있을까요??

해결됨

Next + React Query로 SNS 서비스 만들기

기본적으로 캐싱된 데이터가 있으면, 그 데이터를 가지고 오는 것으로 알고 있는데, const { data} = useQuery({ queryKey: ['posts', 'recommends'], queryFn: getPostRecommends}); const data = queryClient.getQueryData(['posts', 'recommends']); 두 가지 차이점이 있는지 궁금합니다.

  • react
  • next.js
  • react-query
  • next-auth
  • msw
oct.wanga 댓글 2 좋아요 -1 조회수 1871

내부 클래스에 @Slf4j를 적용하는 이유

미해결

스프링 DB 2편 - 데이터 접근 활용 기술

강의에서 내부 클래스에도 @Slf4j를 적용하는 것을 확인할 수 있는데 그 이유가 궁금합니다! @Slf4j @SpringBootTest public class TxBasicTest { @Slf4j static class BasicService { } }

  • spring
  • mvc
  • jpa
  • querydsl
  • spring-data-mybatis
  • spring-jpa
Jaesang Yoon 댓글 1 좋아요 0 조회수 411

@Transactional 적용 (Spring Data JPA, JPA 상황에 따른..)

해결됨

스프링 DB 2편 - 데이터 접근 활용 기술

섹션 8의 <실용적인 구조> 강의에서 질문드립니다. JPA의 모든 데이터 변경은 트랜젝션 안에서 일어나기 때문에 JPA를 사용할 때는 리포지토리 계층에 @Transactional을 붙여야한다고 배웠습니다. 그런데 Spring Data JPA는 @Transactional을 붙이지 않아도 @Transactional 처리를 자동으로 한다는 것 같은데 맞는 얘긴가요? 원래 트랜젝션 적용은 서비스 계층에서 이뤄저야한다고 배웠습니다. 그래서 서비스 계층에서 @Transactional을 붙여왔고요. 그런데 해당 강의의 8분 지점에서 ItemServiceV2의 경우 Spring Data JPA에 의존하고 있기 때문에 리포지토리 계층에서는 @Transactional을 적용하지 않았고 서비스 계층인 ItemServiceV2에서 @Transactional을 적용한 것 같은데 맞을까요?

  • spring
  • mvc
  • jpa
  • querydsl
  • spring-data-mybatis
  • spring-jpa
Jaesang Yoon 댓글 1 좋아요 0 조회수 303

react-intersection-observer 무한스크롤페이지 중복호출문제

미해결

Next + React Query로 SNS 서비스 만들기

안녕하세요 제로초님 강의 잘 보고 있습니다. 다름아니라 무한스크롤 부분 구현중(개인 프로젝트에 해당 부분만 먼저 적용중이라 jsonplaceholder API로 호출하고 있습니다) fetchNextPage가 2번씩호출이 되어서 delay도 조정해보았는데 계속 2번씩호출이 되서 로직에 혹시 문제가 있는지 봐주실수 있을지부탁드립니다. 0. 콘솔에 확인한 결과 처음 화면에 ref가 렌더되고 그 이후 data fetching이 완료되어 isFetcing이 false가 되었는데, data를 map으로 div로 뿌리는 렌더링 과정에 시간이 소모되어 inView는 true && isFetching도 false가 되어서 div가 화면에 나타나고 ref div를 가리기 전에 data fetching을 한번씩 더 하고 있는 상황입니다. 감사합니다

  • react
  • next.js
  • react-query
  • next-auth
  • msw
나무아르볼 댓글 3 좋아요 0 조회수 1370

스프링부트 3. 2. 2 버전에서 Q타입 생성 확인 방법 오류

미해결

스프링 DB 2편 - 데이터 접근 활용 기술

========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? 예 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? 아니오 3. 질문 잘하기 메뉴얼을 읽어보셨나요? 예 [질문 내용] 스프링부트 3.2.2 버전에서 Q타입 생성 확인 시 오류가 발생합니다. Gradle IntelliJ 사용법 build - clean 까지는 정상 작동하지만 compileJava 실행 시 오류가 발생합니다. Gradle 콘솔 사용법 Q 타입 생성 확인 세가지 방법 다 오류가 나는데 도움을 주실 수 있으신가요?? 구글드라이브 링크 https://drive.google.com/file/d/1VOlQN6OXTHgexMiqffrlXFQkIxc4gn-O/view?usp=sharing 오류코드 첨부 Execution failed for task ':compileJava'. > java.lang.NoClassDefFoundError: javax/persistence/Entity * Try: > 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. * Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileJava'. ... Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: javax/persistence/Entity ... Caused by: java.lang.NoClassDefFoundError: javax/persistence/Entity ... Caused by: java.lang.ClassNotFoundException: javax.persistence.Entity

  • spring
  • mvc
  • jpa
  • querydsl
  • spring-data-mybatis
  • spring-jpa
0515 댓글 1 좋아요 0 조회수 699

테스트코드에서 스프링빈 자동 등록시 트랜잭션

미해결

스프링 DB 2편 - 데이터 접근 활용 기술

안녕하세요! 제가 기억이 안 나는지 갑자기 궁금해진 부분이 있습니다. aop class=class hello.springtx.apply.TxBasicTest$BasicService$$SpringCGLIB$$0 강의대로 하니 정상적으로 Proxy 적용 확인할 수 있었습니다 그런데 갑자기 왜 테스트에서 수동으로 스프링 빈 등록을 했었지...? 라는 생각이 들어서 @SpringBootTest(classes = TxBasicTest.BasicService.class) public class TxBasicTest { @TestConfiguration을 주석처리 후 자동으로 빈을 생성할 클래스(BasicService)를 지정했습니다 : aop class=class hello.springtx.apply.TxBasicTest$BasicService Expecting value to be true but was false Expected :true Actual :false 다시 실행해보니 프록시가 적용이 안되어있습니다 왜 프록시가 스프링 컨테이너에 등록되지 않은건지 궁금합니다! @SpringBootTest로 해도 테스트코드에서 @Component 적용 이 안되는건지 궁금합니다

  • spring
  • mvc
  • jpa
  • querydsl
  • spring-data-mybatis
  • spring-jpa
노뚜 댓글 1 좋아요 0 조회수 608

accounts/url 질의

미해결

장고 설계철학으로 시작하는 파이썬 장고 입문

화면과같이 include 부분 강좌와 다르게 저절로 세팅이 되고 서버 실행하면 계속 오류가나는데 어떻게해야하나요ㅜㅜ

  • python
  • django
동휘김 댓글 2 좋아요 0 조회수 260

Test코드 실행 시 findItems에서 오류 발생합니다.

미해결

스프링 DB 2편 - 데이터 접근 활용 기술

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 7:56에서 하신 테스트를 실행했을 때 강의에서는 정상적으로 동작했지만 저는 오류 발생하며 테스트가 정상적으로 되지 않습니다. 오류 로그 테스트 코드에서 item3이 무슨 이유인지 모르지만 같이 넘어가서 문제가 되는 것으로 보입니다. 왜 이럴까요?

  • spring
  • mvc
  • jpa
  • querydsl
  • spring-data-mybatis
  • spring-jpa
Choi근욱 댓글 2 좋아요 1 조회수 578

로그인 버튼 클릭시 500에러 발생

미해결

Next + React Query로 SNS 서비스 만들기

아이디, 비밀번호를 입력하고 로그인 버튼을 누르면 500에러가 발생합니다. 9090 서버 포트는 잘 켜져있다고 뜨고, 코드 올리겠습니다. <auth.ts> import NextAuth from "next-auth"; import CredentialsProvider from "next-auth/providers/credentials"; import KakaoProvider from "next-auth/providers/kakao"; export const { handlers: { GET, POST }, auth, signIn, } = NextAuth({ pages: { signIn: "/i/flow/login", newUser: "i/flow/signup", }, providers: [ CredentialsProvider({ async authorize(credentials) { // credentials 안에 id창에서 입력하는 정보다 담겨있음 const authResponse = await fetch(`${process.env.AUTH_URL}/api/login`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ id: credentials.username, password: credentials.password, //next-auth의 credentials에는 username, password로 고정되어 있어서 이를 바꿔줌 }), }); //로그인 실패시 if (!authResponse.ok) { return null; } const user = await authResponse.json(); return user; }, }), //kakao로그인을 사용할때 // KakaoProvider(), ], }); <LoginModal.tsx> "use client"; import style from "@/app/(beforeLogin)/_component/login.module.css"; import { signIn } from "next-auth/react"; import { useRouter } from "next/navigation"; import { ChangeEventHandler, FormEventHandler, useState } from "react"; export default function LoginModal() { const [id, setId] = useState(""); const [password, setPassword] = useState(""); const [message, setMessage] = useState(""); const router = useRouter(); const onSubmit: FormEventHandler<HTMLFormElement> = async (e) => { e.preventDefault(); setMessage(""); try { await signIn("credentials", { username: id, password, redirect: false, }); //kakao, naver로 바꿀 수 있음 //client 일때는 next-auth/react의 signIn을 사용 //server 일때는 @/auth의 signIn을 사용 router.replace("/home"); } catch (error) { console.log(error); setMessage("아이디와 비밀번호가 일치하지 않습니다."); } }; const onClickClose = () => { router.back(); }; const onChangeId: ChangeEventHandler<HTMLInputElement> = (e) => { setId(e.target.value); }; const onChangePassword: ChangeEventHandler<HTMLInputElement> = (e) => { setPassword(e.target.value); }; return ( <div className={style.modalBackground}> <div className={style.modal}> <div className={style.modalHeader}> <button className={style.closeButton} onClick={onClickClose}> <svg width={24} viewBox="0 0 24 24" aria-hidden="true" className="r-18jsvk2 r-4qtqp9 r-yyyyoo r-z80fyv r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-19wmn03" > <g> <path d="M10.59 12L4.54 5.96l1.42-1.42L12 10.59l6.04-6.05 1.42 1.42L13.41 12l6.05 6.04-1.42 1.42L12 13.41l-6.04 6.05-1.42-1.42L10.59 12z"></path> </g> </svg> </button> <div>로그인하세요.</div> </div> <form onSubmit={onSubmit}> <div className={style.modalBody}> <div className={style.inputDiv}> <label className={style.inputLabel} htmlFor="id"> 아이디 </label> <input id="id" className={style.input} value={id} onChange={onChangeId} type="text" placeholder="" /> </div> <div className={style.inputDiv}> <label className={style.inputLabel} htmlFor="password"> 비밀번호 </label> <input id="password" className={style.input} value={password} onChange={onChangePassword} type="password" placeholder="" /> </div> </div> <div className={style.message}>{message}</div> <div className={style.modalFooter}> <button className={style.actionButton} disabled={!id && !password}> 로그인하기 </button> </div> </form> </div> </div> ); } <middleware.ts> export { auth as middleware } from "./auth"; export const config = { matcher: ["/compose/tweet", "/home", "/explore", "/messages", "/search"], }; <route.ts> export { GET, POST } from "@/auth"; 에러 내용 : TypeError: next_dist_server_web_exports_next_request__WEBPACK_IMPORTED_MODULE_0__ is not a constructor at reqWithEnvURL (webpack-internal:///(rsc)/./node_modules/next-auth/lib/env.js:15:12) at httpHandler (webpack-internal:///(rsc)/./node_modules/next-auth/index.js:139:139) at /Users/imhwarang/projects/zerocho/z-com/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:63815 at /Users/imhwarang/projects/zerocho/z-com/node_modules/next/dist/server/lib/trace/tracer.js:133:36 at NoopContextManager.with (/Users/imhwarang/projects/zerocho/z-com/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7062) 너무 길어서 다 올릴수는 없네요 에러내용을

  • react
  • next.js
  • react-query
  • next-auth
  • msw
화랑 댓글 3 좋아요 0 조회수 1237

인기 태그

인프런 TOP Writers

주간 인기글