묻고 답해요
161만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]
에러 발생 코드 관련 질문입니다.
//BookService @Service public class BookService { private final BookRepository bookRepository; private final UserLoanHistoryRepository userLoanHistoryRepository; private final UserRepository userRepository; public BookService( BookRepository bookRepository, UserLoanHistoryRepository userLoanHistoryRepository, UserRepository userRepository ) { this.bookRepository = bookRepository; this.userLoanHistoryRepository = userLoanHistoryRepository; this.userRepository = userRepository; } @Transactional public void saveBook(BookCreateRequest request) { bookRepository.save(new Book(request.getName())); } @Transactional public void loanBook(BookLoanRequest request) { // 1. 책 정보를 가져온다. Book book = bookRepository.findByName(request.getBookName()) .orElseThrow(IllegalArgumentException::new); // 2. 대출기록 정보를 확인해서 대출중인지 확인한다. // 3. 만약에 확인해는데 대출 중이라면 예외를 발생시킨다. if (userLoanHistoryRepository.existsByBookNameAndIsReturn(book.getName(), false)) { throw new IllegalArgumentException("이미 대출되어 있는 책입니다"); } // 4. 유저 정보를 가져온다. User user = userRepository.findByName(request.getUserName()) .orElseThrow(IllegalArgumentException::new); // 5. 유저 정보와 책 정보를 기반으로 UserLoanHistory를 저장 userLoanHistoryRepository.save(new UserLoanHistory(user.getId(), book.getName())); } } 북서비스 코드인데요// 1. 책 정보를 가져온다. Book book = bookRepository.findByName(request.getBookName()) .orElseThrow(IllegalArgumentException::new);이 부분에서 // 2. 대출기록 정보를 확인해서 대출중인지 확인한다. // 3. 만약에 확인해는데 대출 중이라면 예외를 발생시킨다. if (userLoanHistoryRepository.existsByBookNameAndIsReturn(book.getName(), false)) { throw new IllegalArgumentException("이미 대출되어 있는 책입니다"); } 이 부분 처럼 "존재하지 않는 책입니다" 라는 메세지를 터미널(콘솔인가요? 이거 찍히는 곳 명칭이 터미널인지 콘솔인지 모르겠네요) 에 찍어주려면 어떻게 해야하나요? 그리고 첫 번째 경우와 두 번째 경우에 에러를 발생시키는 방법이 다른 이유는 무엇인지 궁금합니다.
-
미해결자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]
글동록하는부분에서 등록을 하고나면 나이부분에 값이 00세라고들어가네요 이유가뭘까요??
객채셍성하고 등록화면부분올려드렷어요
-
미해결MySQL 성능 최적화
Task2는 직접해보는 부분인가요?
Task1만 하시고 끝나서 그런데 Task2는 직접 하는건지 강의가 추후에 올라오는 건지 궁금합니다
-
미해결[NarP Series] MVC 프레임워크는 내 손에 [나프1탄]
mysql 설정에서 키가 먹지 않습니다
use database를 하거나 show databases를 해도 계속 사진과 같은 화살표만 다음줄에 나옵니다.어느 것을 입력해도 저러는데 왜그러는건가요?
-
미해결자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]
새로 만든 UserRepository 파일의 위치
UserJdbcRepository 는 repository 패키지 하위에 만들었었는데이 강의에서 새로 만든 UserRepository 는 왜 domain 패키지 하위에 만드는 이유가 궁금합니다.
-
해결됨[개정3판] Node.js 교과서 - 기본부터 프로젝트 실습까지
passport.authenticate is not a function 도와주세요..
passport.authenticate is not a functionTypeError: passport.authenticate is not a function at exports.login (/home/node/app/controllers/auth.js:26:14) at Layer.handle [as handle_request] (/home/node/app/node_modules/express/lib/router/layer.js:95:5) at next (/home/node/app/node_modules/express/lib/router/route.js:144:13) at exports.isNotLoggedIn (/home/node/app/middlewares/index.js:15:9) at Layer.handle [as handle_request] (/home/node/app/node_modules/express/lib/router/layer.js:95:5) at next (/home/node/app/node_modules/express/lib/router/route.js:144:13) at Route.dispatch (/home/node/app/node_modules/express/lib/router/route.js:114:3) at Layer.handle [as handle_request] (/home/node/app/node_modules/express/lib/router/layer.js:95:5) at /home/node/app/node_modules/express/lib/router/index.js:284:15 at Function.process_params (/home/node/app/node_modules/express/lib/router/index.js:346:12) POST /auth/login 500 34.609 ms - 2536GET /main.css 304 2.895 ms - -현재 로그인을 눌렀을 때 이 오류가 생깁니다.해결방법을 모르겠습니다..localStrategy.jsconst passport = require('passport'); const {Strategy: localStrategy} = require('passport-local'); const User = require('../models/user'); const bcrypt = require('bcrypt'); module.exports = () => { passport.use(new localStrategy({ usernameField: 'email', passwordField: 'password', passReqToCallback: 'false' }, async (email, password, done) => { try { const exUser = await User.findOne({ where: {email}}); if (exUser) { const result = await bcrypt.compare(passport, exUser.passport); if(result) { done(null, exUser); } else { done(null, false, {message: '비밀번호가 일치하지 않습니다.'}); } } else { done(null, false, {message: '가입되지 않은 회원입니다.'}); } } catch(error) { console.error(error); done(error); } })); }; controllers/auth.jsconst User = require("../models/user"); const bcrypt = require('bcrypt'); const passport = require("../passport"); exports.join = async (req, res, next) => { const {nick, email, password} = req.body; try { const exUser = await User.findOne({ where: {email}}); if (exUser) { return res.redirect('/join?error=exist'); } const hash = await bcrypt.hash(password, 12); await User.create({ email, nick, password: hash, }); return res.redirect('/'); } catch (error) { console.error(error); next(error); } } //POST /auth/login exports.login = (req, res, next) => { passport.authenticate('local', (authError, user, info) => { if (authError) { console.error(authError); return next(authError); } if (!user) { return res.redirect(`/?loginError=${info.message}`); } return req.login(user, (loginError) => { if (loginError) { console.error(loginError); return next(loginError); } return res.redirect('/'); }); })(req, res, next); }; exports.logout = (req, res, next) => { req.logout(() => { res.redirect('/'); }) } app.jsconst express = require('express'); const cookieParser = require('cookie-parser'); const morgan = require('morgan'); const path = require('path'); const session = require('express-session'); const nunjucks = require('nunjucks'); const dotenv = require('dotenv'); const passport = require('passport'); dotenv.config(); // process.env const pageRouter = require('./routes/page'); const authRouter = require('./routes/auth'); const { sequelize } = require('./models'); const passportConfig = require('./passport'); const app = express(); passportConfig(); app.set('port', process.env.PORT || 8080); app.set('view engine', 'html'); nunjucks.configure('views', { express: app, watch: true, }); sequelize.sync({ force: false }) .then(() => { console.log('데이터베이스 연결 성공'); }) .catch((err) => { console.error(err); }); app.use(morgan('dev')); app.use(express.static(path.join(__dirname, 'public'))); app.use(express.json()); app.use(express.urlencoded({ extended: false })); app.use(cookieParser(process.env.COOKIE_SECRET)); app.use(session({ resave: false, saveUninitialized: false, secret: process.env.COOKIE_SECRET, cookie: { httpOnly: true, secure: false, }, })); app.use(passport.initialize()); app.use(passport.session()); app.use('/', pageRouter); app.use('/auth', authRouter); app.use((req, res, next) => { const error = new Error(`${req.method} ${req.url} 라우터가 없습니다.`); error.status = 404; next(error); }); app.use((err, req, res, next) => { res.locals.message = err.message; res.locals.error = process.env.NODE_ENV !== 'production' ? err : {}; res.status(err.status || 500); res.render('error'); }); app.listen(app.get('port'), () => { console.log(app.get('port'), '번 포트에서 대기중'); });
-
미해결비전공자를 위한 풀스택 맛집지도 만들기 프로젝트!: Front, Back-end 그리고 배포까지
인스턴스 중단 후 재시작
프로젝트를 완성하고 aws 인스턴스 프리티어 사용량이 제한량에 거의 도달해서 항상 켜놓으면 안되겠다고 생각해서 잠깐 중단시켰다가 며칠후에 재시작 시켰는데 재시작 한 이후로 지도상에 핀이 안 보이는데 어떻게 해야할까요? pm2도 해놔서 인스턴스를 중단했다가 재시작한것 때문인거 같은데... mysql을 접속하려 했을때 이런 창이 뜹니다.
-
해결됨자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]
intellij 콩모양 질문
따로 마우스를 올려도 콩모양은 보지지 않는데, ultimate 버전에서 지원되는 기능일까요?
-
해결됨자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]
스프링 부트 3.0.1 자바 버전 호환성
A problem occurred configuring root project 'library-app'. > Could not resolve all files for configuration ':classpath'. > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.1. Required by: project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.0.1 > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.1 was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.5' but: - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1 declares a library, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 11 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '7.5') - Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1 declares a runtime of a component, 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 11) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '7.5') - Variant 'mavenOptionalApiElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.0.1 declares a library, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 11 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '7.5') - Variant 'mavenOptionalRuntimeElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.0.1 declares a runtime of a library, 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 11 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '7.5') - Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1 declares a runtime of a library, 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 11 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '7.5') - Variant 'sourcesElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1 declares a runtime of a component, 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 11) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '7.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. 수업자료로 제공되는 압축파일을 받았는데요. jdk 11 설치 후 gradle sync를 누르면 위와 같은 에러가 나오는데요. 강의 설명에서는 11을 깔라고 하셔서 진행하는데 잘 안되네요.build.gradle 파일에 다음과 같이 선언되어 있는데, 스프링부트 3.0.1 버전에서는 17이 호환되는 거 같아서 질문드립니다. jdk 17깔고 설정하니 gradle install은 잘 되네요.```plugins { id 'org.springframework.boot' version '3.0.1' id 'io.spring.dependency-management' version '1.0.12.RELEASE' id 'java' }```
-
미해결[리뉴얼] 처음하는 SQL과 데이터베이스(MySQL) 부트캠프 [입문부터 활용까지]
수업 강의 자료라는 것은 어느 메뉴로 들어가야하나요
수업 강의 자료라는 것은 어느 메뉴로 들어가야하나요???? 메뉴를 찾을 수가 없어요..
-
해결됨자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]
spring.start.io 자바버전 11 미지원
자바 버전이 17부터 나오는데, 강의에서는 11로 진행해서 어떻게 진행하면 될지 여쭤봅니다.
-
미해결[개정3판] Node.js 교과서 - 기본부터 프로젝트 실습까지
정주행 시작했습니다. 강의 PPT 파일은 어디서 다운 받을수있나요?
정주행 시작했습니다. 강의 PPT 파일은 어디서 다운 받을수있나요?
-
미해결[리뉴얼] 처음하는 SQL과 데이터베이스(MySQL) 부트캠프 [입문부터 활용까지]
강의자료를 통해서 요약한 내용을 블로그로의 사용여부
강의자님 강의자료를 통해서 노트에 학습 내용을 개인적으로 요약해서 개인 블로그에 공부 기록을 목적으로 사용하고 싶은데 가능할까요?
-
미해결[리뉴얼] 처음하는 SQL과 데이터베이스(MySQL) 부트캠프 [입문부터 활용까지]
데이터 삭제 후 다시 데이터 추가 시 질문
id(id는 auto increment 설정)와 name 등의 데이터를 5개를 추가한 후, delete from 을 통해 삭제하고 다시 데이터를 넣으니, id가 1부터 다시 지정되는 것이아닌 6부터 지정이 되더라구요..삭제 후, 다시 id를 1부터 하게 할 순 없을까요..?
-
미해결자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]
java.lang.IllegalArgumentException: null
먼저 대출 기능 만들기 강의를 듣다가 문제를 2개 발견하였습니다. 유저 등록부터 'java.lang.IllegalArgumentException: null' 가 생깁니다.... 진짜 전에 잘 되던 것이 갑자기 왜 안되는지 막막합니다....그리고 대출 기능도 'java.lang.IllegalArgumentException: null' 가 생깁니다....이건 혹시 유저 부분에서 등록이 안되는 부분 때문에 생기는 오류인건지...부탁드립니다.. 똑같이 대출 기능 만들기 부분에서 생기는 건데, 위의 오류 문제를 해결하려고 형변환을 없애다 보니 아래와 같이 빨간줄이 나옵니다.. 왜 이러는 걸까요...ㅠㅠ구글 링크로 파일 업로드 했으니, 혹시나 참고해서 말씀하실 부분 있으시면 말씀 부탁드립니다.https://drive.google.com/file/d/1X9s-VjcAeBurdxOYrIOzwa0yZNNoue54/view?usp=sharinghttps://drive.google.com/drive/folders/1vB-XwaSlIKfY2Diq66g6JnQ8vyKVWQvn?usp=sharing
-
해결됨[개정3판] Node.js 교과서 - 기본부터 프로젝트 실습까지
cjs방식인 이유가 있으신가요? require, import
강의에 나온대로 require()로 따라하던 중 import가 더 최신방식이라는 이야기를 듣게 되었습니다. 구글링을 해보니require()를 쓰는 쪽은 CommonJS(CJS)이고 import 쓰는 쪽이 ESM이라는 걸 알게되었습니다Es6(2015)부터 import를 쓸 수 있던거 같은데그 이후에 나온 강의가 require를 쓰게된 이유가 있을까요?사용되는 패키지의 호환성 이슈인지 다른 이유인지 궁금합니다
-
미해결자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]
초반 프로젝트 설정 (build 관련)
안녕하세요인텔리제이에서 프로젝트를 open>build>LibraryAppApplication run을 하면 아래 화면에서 더이상 진행되지 않습니다.Started LibraryAppApplication in 3.292 seconds (JVM running for 3.791) 라는 메세지가 마지막에 출력되나좌측에 상태를 보면 '빌드 중'으로 계속 출력되고 있습니다. 추가로 확인해봐야 하는 설정이 있으면 안내 부탁드립니다.
-
미해결비전공자의 전공자 따라잡기 - 데이터베이스,SQL
일대다, 다대다 관계 질문
[일대일,일대다,다대다 관계(ERD)] 강의 4분 17초에 관한 질문입니다. 일대일, 일대다, 다대다 관계에 대한 개념은 이해됐습니다.그런데 노란색 자막이 이해되지 않습니다.[사원]과 [사원-프로젝트]가 왜 일대다 관계인가요?[사원-프로젝트] 테이블에 의하면사원 하나는 여러 프로젝트를 가질 수 있고,프로젝트 하나는 여러 사원에 할당될 수 있는거 아닌가요?저는 [사원]과 [사원-프로젝트]가 다대다 관계라고 생각했는데 일대다 관계라고 하셔서 질문합니다.
-
미해결비전공자를 위한 풀스택 맛집지도 만들기 프로젝트!: Front, Back-end 그리고 배포까지
이미지 부분에 cctv 영상을 넣고 싶은데요.
이미지 부분에 cctv 영상을 구현하고 싶은데, 혹시 .... api를 연동해서 어떻게 연결하면 되는지 알 수 있을까요?
-
미해결비전공자를 위한 풀스택 맛집지도 만들기 프로젝트!: Front, Back-end 그리고 배포까지
노션 링크가 어디있나요 ?
노션 링크가 어디있나요 ? 찾기가 어렵네요..