STS
STS 4.18.1버전으로 다운 받는다 (최신 버전은 web developer 지원이 안 된다)
이전버전 STS 받는 곳
https://github.com/spring-projects/sts4/wiki/Previous-Versions
웹 관련 (HTML, JSP 등)을 지원하지 않는다면,
마켓플레이스에서 다음 플러그인을 다운 받는다
project 생성
Type : Maven (War) 선택 or Gradle (Jar) 선택
Package : War 선택 (Maven이면) or Jar 선택 (Gradle이면)
Developer Tools에서 Spring Boot DevTools, Lombok 선택
SQL에서 Spring Data JDBC, MyBatis Framework, Oracle Driver 선택
Web에서 Spring Web 선택
window > preferences > Maven > User Setiings > 아래 있는 Repository 경로를 Repository 안의 settings.xml 선택
application.propertires
#server number change
server.port=9000
server.servlet.session.timeout=30m
#oracle setting
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
Maven 라이브러리 추가
tomcat embed jasper Maven 검색해서 복사 후 pom.xml 붙여넣기
<!-- https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-jasper -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>11.0.0-M11</version>
</dependency>
javax servlet jstl Maven 검색해서 복사 후 pom.xml 붙여넣기
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
org.mybatis Maven 검색해서 복사 후 pom.xml 붙여넣기
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.13</version>
</dependency>
mybatis-spring Maven 검색해서 복사 후 pom.xml 붙여넣기
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>3.0.2</version>
</dependency>
pom.xml 전체 코드
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.7</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.himidia</groupId>
<artifactId>springBoard</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>springBoard</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
<!-- mybatis start -->
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>3.0.2</version>
</dependency>
<!-- mybatis end -->
<!-- add start 202310-->
<!-- https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-jasper -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- add end-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter-test</artifactId>
<version>3.0.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
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>
resource는 마지막에 파일을 war로 말면 resource 안에 있던 파일들이 WEB-INF > class 폴더에 들어간다
WEB-INF > classes : 자바 번역본, JSP, xml 등이 다 들어간다. class Not Exception이 여기 class 폴더에서 파일을 찾을 수 없다고 뜨는 것이다.
lib(라이브러리 폴더)가 없을텐데, pom.xml에 다 설정 되어 있는 것이다.