eajni IT ์ดˆ๋ณด์‚ฌ์ „ ๐Ÿ’ฆ๐Ÿ’ฆ

[SpringBoot] Springboot shop project setting

2022-12-20

build.gradle

dependencies {

		//thymeleaf ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
		implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
		implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'
		implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
		// implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6:3.1.1.RELEASE'
		
		//sprinng security ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
		implementation 'org.springframework.boot:spring-boot-starter-security'
		testImplementation 'org.springframework.security:spring-security-test'
		
		//Spring Starter Web :MVC ๋ชจ๋ธ ๊ฐœ๋ฐœ ์‹œ ํ•„์š”ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
		implementation 'org.springframework.boot:spring-boot-starter-web'
		
		//lombok ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
		compileOnly 'org.projectlombok:lombok'
		annotationProcessor 'org.projectlombok:lombok'
		
		//devtools ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ (์ˆ˜์ •์‚ฌํ•ญ ๋ฐ˜์˜ ์ž๋™ restart)
		developmentOnly 'org.springframework.boot:spring-boot-devtools'
		
		//Test ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
		testImplementation 'org.springframework.boot:spring-boot-starter-test'
		
		
		//๋งˆํฌ๋‹ค์šด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜ (2์›” 17์ผ) - ๋งˆํฌ๋‹ค์šด : github์˜ readme.md์™€ ์œ ์‚ฌํ•œ ์‚ฌ์šฉ
		implementation 'org.commonmark:commonmark:0.21.0'
		
		//JPA ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
		implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
		
		// QueryDSL
		implementation 'com.querydsl:querydsl-jpa:5.0.0'
		implementation 'com.querydsl:querydsl-apt:5.0.0'
		implementation 'com.querydsl:querydsl-core:5.0.0' // ํ•œ๊ฐœ ๋” ์ถ”๊ฐ€!
		
		//oracle ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
		//implementation 'com.oracle.database.jdbc:ojdbc10'
		implementation 'com.oracle.database.jdbc:ojdbc11'
		
		//JDBC
		implementation 'org.springframework.boot:spring-boot-starter-jdbc'
		
		//javax : spring boot 2.3 ์ด์ƒ์—์„œ ์‚ฌ์šฉ ์„ค์ •
		implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation', version: '2.5.4'
		
		//model mapper
		implementation group: 'org.modelmapper', name: 'modelmapper', version: '2.3.9'

}

application.properties

#์ฝ”๋“œ ๋’ค ๊ณต๋ฐฑ ์—†๋„๋ก ์œ ์˜
# ์„œ๋ฒ„ ํฌํŠธ ์„ค์ •
server.port=9494
#ํ”„๋กœ์ ํŠธ ์ด๋ฆ„ ์ง€์ •
spring.application.name=shop

# DevTools ํ™œ์„ฑํ™” 
spring.devtools.livereload.enabled=true
spring.freemarker.cache=false

# JPA ( JPA๋Š” H2 DB์™€ ์—ฐ๊ฒฐ ์„ค์ •, ๋ณ€๊ฒฝ์‚ฌํ•ญ๋งŒ ์—…๋ฐ์ดํŠธ๋จ)
# ๋ฐฐํฌ์‹œ์—๋Š” none / validate (update = ๊ฐœ๋ฐœ ์‹œ ์‚ฌ์šฉ) 
spring.jpa.hibernate.ddl-auto=update

# JPA ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ JPA๊ฐ€ SQL ์ฟผ๋ฆฌ๋ฅผ ์ƒ์„ฑํ•ด์„œ DB์— ์ €์žฅ ํ•จ. 
# ( Oracle, MySQL, MSSQL...)  ์ฟผ๋ฆฌ ๋‚ด์šฉ์ด ์ฝ˜์†”์— ์ถœ๋ ฅ ๋˜๋„๋ก ์„ค์ •
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.show_sql=true

# Orale DB ์—ฐ๊ฒฐ
# spring.datasource.url=jdbc:oracle:thin:@localhost:1521:xe
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:xe
spring.datasource.username=C##shop
spring.datasource.password=1234
spring.datasource.driverClassName=oracle.jdbc.driver.OracleDriver
spring.jpa.database=oracle

spring.jpa.database-platform=org.hibernate.dialect.OracleDialect

#์ฟผ๋ฆฌ์— ๋ฌผ์Œํ‘œ๋กœ ์ถœ๋ ฅ๋˜๋Š” ๋ฐ”์ธ๋“œ ํŒŒ๋ผ๋ฏธํ„ฐ ์ถœ๋ ฅ(?, ?, ?, ?)
logging.level.org.hibernate.type.descriptor.sql=trace

#Thymeleaf cache ์‚ฌ์šฉ ์ค‘์ง€
spring.thymeleaf.cache = false

#ํŒŒ์ผ ํ•œ ๊ฐœ๋‹น ์ตœ๋Œ€ ์‚ฌ์ด์ฆˆ
spring.servlet.multipart.maxFileSize=20MB
#์š”์ฒญ๋‹น ์ตœ๋Œ€ ํŒŒ์ผ ํฌ๊ธฐ
spring.servlet.multipart.maxRequestSize=100MB
#์ƒํ’ˆ ์ด๋ฏธ์ง€ ์—…๋กœ๋“œ ๊ฒฝ๋กœ ์ง€์ •
itemImgLocation=C:/shop/item
#๋ฆฌ์†Œ์Šค ์—…๋กœ๋“œ ๊ฒฝ๋กœ์ง€์ •
uploadPath=file:///C:/shop/

#๊ธฐ๋ณธ batch size ์„ค์ •
spring.jpa.properties.hibernate.default_batch_fetch_size=1000

Oracle

# ๊ณ„์ • ์ƒ์„ฑ
create user C##shop identified by 1234;

# HR ๊ณ„์ •์˜ ๊ถŒํ•œ ๋ถ€์—ฌ
grant connect, resource to C##shop;

# ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค ์‚ฌ์šฉ ๊ถŒํ•œ ๋ถ€์—ฌ
alter user C##shop quota unlimited on USERS;

Comments

Content