STS
STS 4.18.1버전으로 다운 받는다 (최신 버전은 web developer 지원이 안 된다)
https://github.com/spring-projects/sts4/wiki/Previous-Versions
웹 관련 (HTML, JSP 등)을 지원하지 않는다면,
마켓플레이스에서 다음 플러그인을 다운 받는다
project 생성
Type : Gradle 선택
Package : Jar 선택
(회원관리)
application.propertires
spring.datasource.username=c##scott
spring.datasource.password=1234
#spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
#spring.datasource.url=jdbc:oracle:thin:@127.0.0.1:1521:xe
spring.datasource.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
spring.datasource.url=jdbc:log4jdbc:oracle:thin:@127.0.0.1:1521:xe
server.port=9001
spring.main.banner-mode=off
server.servlet.session.timeout=30m
logging.level.jdbc.sqlonly=DEBUG
logging.level.org.springframework.web=DEBUG
logging.level.com.zaxxer.hikari.HikariDataSource: ERROR
# mapper 로그레벨 설정
logging.level.com.azurealstn.codespringweb.mapper=TRACE
#전체 로그 레벨 설정(기본 info)
logging.level.root=info
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp
server.servlet.jsp.init-parameters.development=true
#mybatis.type-aliases-package=com.ecom4.custom.model,com.ecom4.product.model
mybatis.config-location=classpath:/mybatisConfig/Mybatis-Config.xml
mybatis.mapper-locations=classpath:**/mapper/*Mapper.xml
logging.level.net.chndol.stydy.maybatisssampl.mapper=INFO
Gradle 라이브러리 추가
jstl gradle 검색해서 복사 후 gradle(short) 복사해서 build.gradle의 implementation에 붙여넣기
implementation 'javax.servlet:jstl:1.2'
tomcat-embed-jasper gradle 검색해서 복사 후 gradle(short) 복사해서 build.gradle의 implementation에 붙여넣기
implementation 'org.apache.tomcat.embed:tomcat-embed-jasper:10.1.9'
log4jdbc-log4j2-jdbc4.1 검색해서 복사 후 gradle(short) 복사해서 build.gradle의 implementation에 붙여넣기
implementation 'org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4.1:1.16'
spring-boot-starter gradle 검색해서 복사 후 gradle(short) 복사해서 build.gradle의 implementation에 붙여넣기
implementation 'org.springframework.boot:spring-boot-starter'
TagLibraryValidator gradle 검색해서 복사 후 gradle(short) 복사해서 build.gradle에 붙여넣기
compileOnly 'javax.servlet.jsp:jsp-api:2.0'
build.gradle 전체 코드
plugins {
id 'java'
id 'org.springframework.boot' version '3.1.4'
id 'io.spring.dependency-management' version '1.1.3'
}
group = 'com.ecom4'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '17'
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation group: 'org.glassfish.web', name: 'jakarta.servlet.jsp.jstl', version: '2.0.0'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-web-services'
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.2'
implementation 'org.springframework.session:spring-session-core'
implementation 'org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4.1:1.16'
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.apache.tomcat.embed:tomcat-embed-jasper:10.1.9'
compileOnly 'org.projectlombok:lombok'
compileOnly 'org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4:1.16'
compileOnly group: 'javax.servlet.jsp', name: 'jsp-api', version: '2.0'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.oracle.database.jdbc:ojdbc8'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter-test:3.0.2'
}
tasks.named('test') {
useJUnitPlatform()
}
logback.xml
src/main/resources 폴더에 넣기
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
<appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>D:\ljs\Ecom_Work_js\logs\boardLog.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>D:\ljs\Ecom_Work_js\logs\boardLog-%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%-5level] - %msg%n</Pattern>
</layout>
</appender>
<!-- Loggers -->
<!-- <logger name="org.apache.catalina" level="ERROR">
</logger>
<logger name="org.apache.commons" level="ERROR">
</logger> -->
<!-- <logger name="org.springframework" level="DEBUG" >
</logger> -->
<!-- <logger name="java.sql" level="DEBUG">
</logger> -->
<logger name="org.mybatis.spring" level="DEBUG">
</logger>
<root level="DEBUG">
<appender-ref ref="ROLLING"/>
<appender-ref ref="STDOUT" />
</root>
</configuration>
Mybatis -Config.xml
src/main/resource > mybatisConfig > Mybatis -Config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "HTTP://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="cacheEnabled" value="false" />
<setting name="useGeneratedKeys" value="true" />
<setting name="defaultExecutorType" value="REUSE" />
<setting name="jdbcTypeForNull" value="NULL" />
</settings>
<!-- aliaes - short name setting bvo, pvo-->
<typeAliases>
<typeAlias alias="hashMap" type="java.util.HashMap" />
<typeAlias alias="map" type="java.util.Map" />
#<typeAlias alias="mdto" type="com.ecom4.custom.dto.MemberDTO" />
#<typeAlias alias="pdto" type="com.ecom4.product.dto.ProductDTO" />
#<typeAlias alias="pageDto" type="com.ecom4.common.dto.PageDTO" />
#<typeAlias alias="odto" type="com.ecom4.order.dto.OrderDTO" />
</typeAliases>
</configuration>