관리 메뉴

진취적 삶

9.1 프로젝트 생성 본문

스프링 5 프로그래밍 입문/9.스프링 MVC 시작하기

9.1 프로젝트 생성

hp0724 2023. 9. 11. 09:00

pom.xml 에 값으로 war

서블릿 /JSP 을 이용한 웹 어플리케이션 개발할 경우 war를 값으로 주어야 한다.

<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>
  <groupId>sp5</groupId>
  <artifactId>sp5-chap09</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  
  <dependencies>
	  <dependency>
		  <groupId>javax.servlet</groupId>
		  <artifactId>javax.servlet-api</artifactId>
		  <version>3.1.0</version>
		  <scope>provided</scope>
	  </dependency>
	  
	  <dependency>
		  <groupId>javax.servlet.jsp</groupId>
		  <artifactId>javax.servlet.jsp-api</artifactId>
		  <version>2.3.2-b02</version>
		  <scope>provided</scope>
	  </dependency>
	  
	   <dependency>
		  <groupId>javax.servlet</groupId>
		  <artifactId>jstl</artifactId>
		  <version>1.2</version>
	  </dependency>
	  
	  <dependency>
		  <groupId>org.springframework</groupId>
		  <artifactId>spring-webmvc</artifactId>
		  <version>5.0.2.RELEASE</version>
	  </dependency>
  </dependencies>
  <build>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.7.0</version>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<encoding>utf-8</encoding>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

의존 설정

build.gradle

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'

sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = "UTF-8"

repositories {
    mavenCentral()
}

dependencies {
    providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
    providedRuntime 'javax.servlet.jsp:javax.servlet.jsp-api:2.3.2-b02'
    compile 'javax.servlet:jstl:1.2'
    compile 'org.springframework:spring-webmvc:5.0.2.RELEASE'
}

task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
}