[Spring] ๋ฉ์ด๋ธ(Maven)๊ณผ pom.xml
๐pom.xml ์ ์
pom.xml์ ๋ฉ์ด๋ธ(Maven)์ ๋น๋ ์ ๋ณด๋ฅผ ๋ด๊ณ ์๋ ํ์ผ์ด๋ค.
๐์ฌ๊ธฐ์ ๋ฉ์ด๋ธ(Maven)์ด๋?
์๋ฐ ํ๋ก์ ํธ ๊ด๋ฆฌ ํด์ผ๋ก, ๋ฏธ๋ฆฌ ์์ฑ๋ xml ํ์ผ์ ์ฌ์ฉํ์ฌ ํ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋ค์ด๋ก๋ํ๊ฑฐ๋, ์์ฑ, ํ๋ก์ ํธ ๋น๋ ํ๋ ๋ฑ์ ์์ ์ ์๋ํํ๋ค. ๋ฉ์ด๋ธ์ ๊ธฐ๋ฅ์๋ ๋๋ต 1) ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๊ด๋ฆฌ 2) ๋น๋ ๊ธฐ๋ฅ์ด ์๋ค.๋ํ, pom.xml์ ๋ค๋ฅธ ํ๋ก์ ํธ์ ๋ณต์ฌ/๋ถ์ฌ๋ฃ๊ธฐ๊ฐ ๊ฐ๋ฅํ๊ธฐ ๋๋ฌธ์ ๋ฒ์ฉ์ฑ์ด ์ข๋ค. STS(Spring Tools Suite)๋ ์ด๋ฌํ ๋ฉ์ด๋ธ์ ๋ด์ฅํ๊ณ ์๋ค. ๋ฉ์ด๋ธ์ ์ด pom.xml์ ์ฐ์ฌ์ง ๋ด์ฉ์ ๋ฐํ์ผ๋ก ํ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋ค์ด๋ก๋ํ๊ฑฐ๋ ๋ด์ฅํด์ ํ๋ก๊ทธ๋จ์ ๋น๋ํ๊ณ ์คํํ๋ค. ๋ฉ์ด๋ธ์ ์ฌ์ฉํ ํ๋ก์ ํธ์์๋ pom.xml์ ์ผ๋ง๋ ์ ๋๋ก ์ค์ ํ๋๋๊ฐ ์ค์ํ๋ค.
๐pom.xml์ ๊ธฐ๋ณธ ํํ
pom.xml์ ํ์ผ ํ์์ด XML์ด๋ฏ๋ก ํ๊ทธ ํํ๋ก ๊ตฌ์ฑ๋์ด ์๋ค.
<project> ํ๊ทธ : ๋ฃจํธ ํ๊ทธ์ด๋ฉฐ ๋ฉ์ด๋ธ์ XML ๋ค์์คํ์ด์ค๋ฅผ ์ง์ ํ๋ค.
<modelVersion> : ๋ฉ์ด๋ธ์ ๋ชจ๋ธ ๋ฒ์
<groupID> : ๊ทธ๋ฃน ID์ ํ๊ทธ
<artifactID> : ์ํฐํฉํธID์ ํ๊ทธ
<version> : ๋ฒ์ ๋ช ํ๊ทธ
<packaging> : ํจํค์ง ํ์์ ์ง์ ํ๋ ํ๊ทธ ex) war
<name> : ํ๋ก์ ํธ ์ด๋ฆ
<url> : ๋ฉ์ด๋ธ์ url
<properties> : ํ๋ก์ ํธ ๊ด๋ จ ์์ฑ
<parent> : pom.xml์ ์์์ ๊ด๋ จ๋ ํ๊ทธ
<dependencies> : ํ๋ก์ ํธ๊ฐ ์์กดํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค์ ์ ๋ณด
<dependency> ์ ๊ดํ์ฌ
<dependency>๋ ํ๋ก์ ํธ์ ์ฌ์ฉํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ ์ํ๋ ํ๊ทธ์ด๋ค.
๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ groupId์ artifactId๋ก ๊ตฌ๋ณ๋๋ฏ๋ก, ์ด ๋ ๊ฐ์ง ํ๊ทธ๋ <dependency>์ ๊ผญ ์ ๋ ฅํด์ฃผ์ด์ผํ๋ค.
- <groupId> : ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๊ทธ๋ฃน ID
- <artifactId> : ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์ํฐํฉํธ ID
- <version> : ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ ๋ฒ์
- <scope> : ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ํ๋ก์ ํธ ๋ด์์ ์ฌ์ฉ๋๋ ๋ฒ์
๐pom.xml ์์
spring MVC Project์ jdbc, spring-test, mybatis ๋ฑ์ ์ถ๊ฐํ๋ค.
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>project</artifactId>
<name>project</name>
<packaging>war</packaging>
<version>1.0.0-BUILD-SNAPSHOT</version>
<properties>
<java-version>1.8</java-version>
<org.springframework-version>3.1.1.RELEASE</org.springframework-version>
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.6.6</org.slf4j-version>
</properties>
<!-- ์ค๋ผํด -->
<repositories>
<repository>
<id>oracle</id>
<url>http://maven.jahia.org/maven2</url>
</repository>
</repositories>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<!-- AspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${org.aspectj-version}</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
<scope>runtime</scope>
</dependency>
<!-- @Inject -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<!-- spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<!-- spring-test -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework-version}</version>
<scope>test</scope>
</dependency>
<!-- log4jdbc-log4j2-jdbc4 -->
<dependency>
<groupId>org.bgee.log4jdbc-log4j2</groupId>
<artifactId>log4jdbc-log4j2-jdbc4</artifactId>
<version>1.16</version>
</dependency>
<!-- org.mybatis/mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.1</version>
</dependency>
<!-- mybatis-spring -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<additionalProjectnatures>
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
</additionalProjectnatures>
<additionalBuildcommands>
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
</additionalBuildcommands>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>org.test.int1.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>