본문 바로가기

분류 전체보기

(124)
[Spring boot] H2 DB 연결 & JPA 실행 & 기타 설정, JPQL이란? H2 DB 연결준비 1. pom.xml (library 셋팅) 4.0.0 jpa-basic ex1-hello-jpa 1.0.0 1.8 1.8 org.hibernate hibernate-entitymanager 5.3.10.Final com.h2database h2 1.4.199 javax.xml.bind jaxb-api 2.3.0 더보기 hibernate version 찾기 spring > spring boot > LEARN > Reference Doc. > Dependency Versions > (ctrl+f) org.hibernate 검색 오른쪽에 버전 확인 후 작성 H2 DB 버전 찾기 설치된 h2 DB와 같은 version으로 작성 설치할 때 Download 아래 써있는 version 확인 2. ..
[Node.js] 프로젝트 생성 및 mongoDB 연결하기 프로젝트 생성 및 설정 1. 프로젝트 시작하기 (내 프로젝트 package화) npm init 더보기 ( * 괄호 안에 값이 있으면 엔터를 쳤을 때 자동으로 설정됩니다. * ) name : 프로젝트 이름 version : 버전 description : 설명 (직접 쓰기를 권장) entry point: 어떤 js파일이 package를 구동시키는 첫 시작인지 test command : TDD(Test Driven Development : 테스트 주도 개발)를 할 때 test를 실행시킬 명령어 git repository : git repo 주소 1-1. 이미 client가 있다면 server 폴더를 만들고 cd server 2. express와 nodemon, mongoose 설치 npm install exp..
[git] LF will be replaced by CRLF in src/App.js. The file will have its original line endings in your working directory 오류 LF will be replaced by CRLF in src/App.js. The file will have its original line endings in your working directory. 오류 발생시 터미널에 명령어 입력하기 git config --global core.autocrlf true 이는 맥 이나 리눅스를 쓰는 개발자와 윈도우 쓰는 개발자가 Git으로 협업할 때 발생하는 Whitespace 에러 리눅스나 맥 개발자는 아래 참고 참고) https://dabo-dev.tistory.com/13 https://blog.jaeyoon.io/2018/01/git-crlf.html
[Node.js] supervisor 서버 자동on/off supervisor 코드를 수정하면 자동으로 node.js를 껐다 키기 때문에 application을 수동으로 껐다 켤 필요가 없다. 메뉴얼 : https://www.npmjs.com/package/supervisor 설치 npm install supervisor -g supervisor app.js
[Node.js] 서버에 데이터 저장 (파일로 저장) 파일로 데이터 저장하기 (데이터 입력) //app.js const fs = require('fs'); app.set('views'. './views_file'); app.set('view engine', 'jade'); app.post('/topic', function(req,res){ const title = req.body.title; const desc = req.body.desc; fs. writeFile('data/'+title, desc, function(err){ if(err){ console.log(err); res.status(500).send('Internal Server Error'); // status(500) : 오류 } res.send('Success!'); }); } }) //..
[Node.js] url 해부하기(query, params), Form으로 데이터 전달 url 해부하기 ex) http://a.com/topic?id=1 http : 프로토콜 a.com : 도메인. 서버 컴퓨터가 위치하는 주소 topic : path. directory명 또는 router와 연결되는 주소 id = 1 : query string url req이 들어오면 해당하는 router에 걸려 res를 해준다. url에 해당하는 router가 없다면 404 에러가 뜬다. query 객체사용법 query를 통해 사용자가 query string으로 요청한 정보를 사용할 수 있다. //http://a.com/topic?name=Baeji => 출력 : Baeji app.get('/topic', function(req, res){ res.send(req.query.name); }) //http:..
[spring boot] 정적 컨텐츠, MVC와 템플릿 엔진, API 정적 컨텐츠 정적 컨텐츠는 파일을 그대로 웹브라우저로 전달하는 것으로, 맨 처음 controller에서 파일을 찾아보고 없다면 resource에서 찾는다. 찾는대로 바로 반환하는 것이 특징이다. (/ 페이지에 접속했을 때 resources/static/index.html 파일이 있다면 이걸 반환, /페이지에 접속했을 때 다른 파일로 연결되도록 지정해줬다면 지정된 파일로 반환) MVC와 템플릿 엔진 MVC와 템플릿 엔진은 서버에서 HTML 템플릿이 있으면 thymeleaf(템플릿엔진)가 view라는 템플릿(html)을 변경, 조작하여 내려주는 방식이다. 소스코드를 보면 변환 된 데이터와 html코드가 보인다는 특징이 있다. 로직을 살펴보자면, 1. 내장 톰켓서버가 "hello-mvc라는게 왔어" 하고 sp..
[spring boot] 프로젝트 생성 및 실행, 빌드 프로젝트 생성 https://start.spring.io 접속 후 Project: Gradle Project Language: Java Spring Boot: 2.5.x (Spring Boot 버전은 SNAPSHOT, M1 같은 미정식 버전을 제외하고 제일 최신 버전을 사용) Packaging: Jar Java: 11 Project Metadata groupId: hello artifactId: hello-spring Dependencies: Spring Web, Thymeleaf, lombok, Lombok, Spring Data JPA, Validation, Spring Boot DevTools 아래 create 버튼을 누르기 압축파일 다운 압축풀기 intellij에서 압축 푼 파일의 bulid.gr..