Springboot

[SpringBoot] 12. 세팅 정리

Song hyun 2024. 8. 6. 17:31
728x90
반응형

(1) application.yml

더보기

server:

port: 8080 #서버가 사용할 포트 번호 설정

servlet:

encoding:

charset: utf-8 #서블릿의 응답과 요청 인코딩을 UTF-8 로 설정

force: true # 요청과 응답에 대해 이 인코딩을 강제로 사용하도록 설정합니다.

 

spring:

mvc:

view:

prefix: /WEB-INF/view/ #JSP파일이 위치한 디렉토리 접두사를 설정합니다.

suffix: .jsp #뷰 이름에 자동으로 추가될 파일 확장자를 설정합니다.

datasource:

url: jdbc:h2:mem:bankdb;MODE=MySQL

driver-class-name: org.h2.Driver #드라이버 클래스를 설정 합니다.

username: sa #사용자 ID를 지정

password: '' #DB 비밀번호 여기서는 빈 문자열로 설정

sql:

init:

schema-locations:

- classpath:db/table.sql

data-locations:

- classpath:db/data.sql

 

h2:

console:

enabled: true #H2 데이터 베이스 콘솔을 활성화 합니다.

 

output:

ansi:

enabled: always #콘솔 출력에 ANSI 색상 코드를 사용할 수 있도록 설정

 

#mybatis 설정

mybatis:

mapper-locations:

- classpath:mapper/**/*.xml #MyBatis 매퍼 파일 위치를 설정합니다. **은 모든 디렉토리, *.xml 은 모든 XML 파일을 의미합니다.

configuration:

map-underscore-to-camel-case: true #데이터베이스의 언더스코어 네이밍(column_name)을 카멜 케이스(columnName)로 자동 매핑합니다.

log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #SQL 로깅 구현체를 설정합니다.

 

logging:

level:

org.apache.ibatis: DEBUG #MyBatis 로깅 레벨을 DEBUG로 설정하여 실행되는 SQL 쿼리와 내부 로깅 정보를 콘솔에 출력합니다.

 

(2) build.gradle

더보기

plugins {

id 'java'

id 'war'

id 'org.springframework.boot' version '3.2.8'

id 'io.spring.dependency-management' version '1.1.6'

}

 

group = 'com.example'

version = '0.0.1-SNAPSHOT'

 

java {

toolchain {

languageVersion = JavaLanguageVersion.of(21)

}

}

 

configurations {

compileOnly {

extendsFrom annotationProcessor

}

}

 

repositories {

mavenCentral()

}

 

dependencies {

// 의존성 추가

implementation 'org.apache.tomcat.embed:tomcat-embed-jasper'

implementation group: 'org.glassfish.web', name: 'jakarta.servlet.jsp.jstl', version: '3.0.0'

// TODO - tools xml 파일 error check

providedCompile 'javax.servlet:javax.servlet-api:3.1.0'

 

implementation 'org.springframework.boot:spring-boot-starter-web'

implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.3'

compileOnly 'org.projectlombok:lombok'

developmentOnly 'org.springframework.boot:spring-boot-devtools'

runtimeOnly 'com.h2database:h2'

runtimeOnly 'com.mysql:mysql-connector-j'

annotationProcessor 'org.projectlombok:lombok'

providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'

testImplementation 'org.springframework.boot:spring-boot-starter-test'

testImplementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter-test:3.0.3'

testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

}

 

tasks.named('test') {

useJUnitPlatform()

}

728x90
반응형