각진 세상에 둥근 춤을 추자
웹 프로젝트 환경 구성 본문
1. 새 프로젝트 만들기
2. build.gradle
(1) tomcat
https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-core/8.5.42
// https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-core
implementation 'org.apache.tomcat.embed:tomcat-embed-core:8.5.42'
https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-jasper/8.5.42
// https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-jasper
implementation 'org.apache.tomcat.embed:tomcat-embed-jasper:8.5.42'
(2) servlet
https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api/4.0.1
// https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api
implementation 'javax.servlet:javax.servlet-api:4.0.1'
(3) jstl
https://mvnrepository.com/artifact/javax.servlet/jstl/1.2
// https://mvnrepository.com/artifact/javax.servlet/jstl
implementation 'javax.servlet:jstl:1.2'
(4) logback
https://mvnrepository.com/artifact/ch.qos.logback/logback-classic/1.2.3
// https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
testImplementation 'ch.qos.logback:logback-classic:1.2.3'
// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
implementation 'org.slf4j:slf4j-api:1.7.25'
3. WebApplicationServer.java
package org.example;
import org.apache.catalina.startup.Tomcat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
public class WebApplicationServer {
private static final Logger log = LoggerFactory.getLogger(WebApplicationServer.class);
public static void main(String[] args) throws Exception {
String webappDirLocation = "webapps/";
Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);
tomcat.addWebapp("/", new File(webappDirLocation).getAbsolutePath());
log.info("configuring app with basedir : {}", new File("./" + webappDirLocation).getAbsolutePath());
tomcat.start();
tomcat.getServer().await();
}
}
4. webapps, WEB-INF 폴더 생성
(1) 프로젝트 - New - Directory
5. Build Tools Setting
(1) Settings - Build, Execution, Deployment - Build Tools - Gradle : Gradle -> Intellij IDEA
6. Project Structure
(1) File - Project Structure - Modules - 프로젝트 main : 경로 build -> webapps/WEB-INF 변경 (뒤 production 지우기)
'Spring' 카테고리의 다른 글
[Spring Boot] log4jdbc & logback으로 SQL 쿼리 콘솔로 보기 (0) | 2024.01.05 |
---|---|
Docker 명령어 모음 (0) | 2023.07.02 |
[Sprint Boot] 로거 생성 및 slf4j를 이용한 로깅 (0) | 2023.01.18 |
[Spring Boot] JUnit으로 실행되는 스프링부트 테스트 (0) | 2023.01.18 |
[Spring Boot] 네이버 검색 API를 이용한 책 목록 조회 (2) | 2023.01.18 |