VS CODE Spring Boot 세팅

merci·2023년 1월 10일
1
post-thumbnail

스프링 부트 세팅

Ctrl+Shift+X 를 눌러서 익스텐션 검색 탭을 연다

  • 설치
  • ctrl shift a 눌러서 진행

  • 여기부터는 수업에 사용한 세팅



  • 3개 체크 ( 기본사항 )

엔터치면 프로젝트 생성됨 + 최초 오픈시 라이브러리 다운받음


디버그 콘솔 색깔 변경



application.yml
톰캣의 .xml 설정과
스프링프레임워크 설정을 한번에 할수 있다 !!!

결과

  • 파일 생성은 프로젝트의 하위에 만들어야 한다






템플릿 엔진 세팅 ( JSP )

  • 설치 ( 현재 지원 안할 수도..)
  • 폴더 추가 (main 하위)

  • 라이브러리 추가 (jsp 파일을 읽을 수 있게 함)
implementation group: 'org.apache.tomcat', name: 'tomcat-jasper', version: '9.0.43'
implementation 'javax.servlet:jstl'
  • 파일의 경로 설정 / ViewResolver 설정 (yml 파일)
spring:
  output:
    ansi:
      enabled: always
      
  // 아래가 ViewRosolver 설정 / 복사할 경우 주석은 삭제할것
  mvc:
    view:
      prefix: /WEB-INF/views/
      suffix: .jsp
  • 이후 @Controller 이용해서 ViewRosolver 발동



우려했던 상황이 발생, JSP 지원이 안되는것 같다.
JSP 파일을 스니펫으로 만들어서 배우자.

jsp.json 에 스니펫 저장 ( 아니면 html.json 에 저장해도 됨 )

{
	"Jsp Template": {
	   "prefix": "jsp",
	   "body": [
		  "<%@ page language=\"java\" contentType=\"text/html; charset=UTF-8\" pageEncoding=\"UTF-8\"%>",
		  "<%@ taglib prefix=\"c\" uri=\"http://java.sun.com/jsp/jstl/core\"%>",
	   ],
	   "description": "Jsp Template"
	}
 }





DB 연결 세팅

  • H2 DB - 드라이버 + 프로그램이 같이 있다

  • JPA

  • yml 세팅

spring:
  datasource:
    url: jdbc:h2:mem:test;MODE=MySQL
    driver-class-name: org.h2.Driver
    username: sa
    password: 
  h2:
    console:
      enabled: true
  jpa:
    open-in-view: true
    hibernate:
      ddl-auto: create
    show-sql: true
  output: 
    ansi:
      enabled: always

번외

  • jstl을 사용하기 위한 추가설치

  • mapper .xml 에서 자동완성

  • xml 에서 사용할 스니펫 추가 ( xml.json )

{
	"Mapper Template": {
		"prefix": "mapper",
		"body": [
			"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>",
			"<!DOCTYPE mapper",
			"  PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\"",
			"  \"http://mybatis.org/dtd/mybatis-3-mapper.dtd\">",
			"",
			"<mapper namespace=\"\">",
			"    <select id=\"findAll\" resultType=\"\">",
			"        select * from  where id = #{id}",
			"    </select>",
			"</mapper>",
		],
		"description": "mapper Template"
	}
}

https://developer.mozilla.org/ko/docs/Web/HTTP/Status - http 상태코드

profile
작은것부터

0개의 댓글