IT 개발노트

war패키징 pom.xml 설정, war file 만들기, web.xml 자동생성 본문

기초튼튼

war패키징 pom.xml 설정, war file 만들기, web.xml 자동생성

limsungju 2019. 9. 10. 11:33

Maven Project WebService pom.xml 설정

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>kr.co.itcen</groupId>
	<artifactId>helloweb</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>
	
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>
	
	<!-- 라이브러리 항목 -->
	<dependencies>
	</dependencies>
	
	<build>
		<sourceDirectory>src/main/java</sourceDirectory>
		<resources>
			<resource>
				<directory>${project.basedir}/src/main/resources</directory>
				<excludes>
					<exclude>**/*.java</exclude>
				</excludes>
			</resource>
		</resources>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-resources-plugin</artifactId> <!-- 컴파일러가 사용하는 플러그인 -->
				<configuration>
					<encoding>UTF-8</encoding>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.8.0</version>
				<configuration>
					<source>1.8</source> <!-- version -->
					<target>1.8</target>
				</configuration>
			</plugin>
			<!-- war plugin -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>3.2.1</version>
				<configuration>
					<warSourceDirectory>src/main/webapp</warSourceDirectory> <!-- war파일 디렉토리 -->
					<failOnMissingWebXml>false</failOnMissingWebXml> <!-- web.xml이 없을 때 에러를 낼건지 안낼건지 -->
				</configuration>
			</plugin>
		</plugins>
	</build>
	
</project>

 

web.xml 자동으로 생성하는 방법
프로젝트 우클릭 -> Java EE Tools -> Generate 클릭 ->

eclipse로 war 만들기
File -> New -> Export -> Web -> WAR file

 

프로젝트 우클릭 -> Run As -> Maven build -> Goals: clean package ->