Maven 으로 프로젝트 설정시에는 의존관계 라이브러리 (*.jar) 파일을 다운로드 받아 WEB-INF/lib 에 따로 설정할 필요가 없이 pom.xml 에 해당 의존관계 라이브러리에 대한 의존관계를 기술해 주면 자동을 관련 라이브러리를 다운로드 받아 프로젝트에서 사용할 수 있게 합니다.
properties 정의
properties Element 는 pom.xml 에서 사용하는 속성을 선언해 줄 수 있습니다. 해당 의존관계 라이브러리의 버전을 일괄적으로 적용하거나 내부 속성등을 설정하는 용도로 사용하시면 됩니다.
properties 에 정의된 속성을 사용할 경우에는 ${속성명} 과 같이 사용하시면 됩니다.
예를 들어 아래의 properties 하위에 정의된 org.springframework.version 속성을 사용하실 경우에는 ${org.springframework.version} 으로 하시면 해당 속성값을 “3.1.1.RELEASE” 로 적용하여 줍니다.
< project.build.sourceEncoding >UTF-8</ project.build.sourceEncoding > < org.springframework.version >3.1.1.RELEASE</ org.springframework.version > < org.slf4j.version >1.5.8</ org.slf4j.version > < org.codehaus.jackson.version >1.9.3</ org.codehaus.jackson.version > </ properties > |
dependencies 정의
dependencies 는 프로젝트에서 사용할 의존관계 라이브러리들을 정의하는 Element 입니다. 아래의 설정을 복사하여 pom.xml 에 붙여 넣습니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | < dependencies > < dependency > < groupId >junit</ groupId > < artifactId >junit</ artifactId > < version >3.8.1</ version > < scope >test</ scope > </ dependency > < dependency > < groupId >javax.servlet</ groupId > < artifactId >jstl</ artifactId > < version >1.2</ version > </ dependency > < dependency > < groupId >javax.servlet.jsp</ groupId > < artifactId >jsp-api</ artifactId > < version >2.2</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >javax.servlet</ groupId > < artifactId >javax.servlet-api</ artifactId > < version >3.0.1</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >taglibs</ groupId > < artifactId >standard</ artifactId > < version >1.1.2</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >aopalliance</ groupId > < artifactId >aopalliance</ artifactId > < version >1.0</ version > </ dependency > < dependency > < groupId >aspectj</ groupId > < artifactId >aspectjweaver</ artifactId > < version >1.5.4</ version > </ dependency > < dependency > < groupId >asm</ groupId > < artifactId >asm</ artifactId > < version >3.3.1</ version > </ dependency > < dependency > < groupId >commons-beanutils</ groupId > < artifactId >commons-beanutils</ artifactId > < version >1.8.0</ version > </ dependency > < dependency > < groupId >commons-dbcp</ groupId > < artifactId >commons-dbcp</ artifactId > < version >1.4</ version > </ dependency > < dependency > < groupId >commons-collections</ groupId > < artifactId >commons-collections</ artifactId > < version >3.2.1</ version > </ dependency > < dependency > < groupId >commons-digester</ groupId > < artifactId >commons-digester</ artifactId > < version >2.0</ version > </ dependency > < dependency > < groupId >commons-fileupload</ groupId > < artifactId >commons-fileupload</ artifactId > < version >1.2.2</ version > </ dependency > < dependency > < groupId >commons-lang</ groupId > < artifactId >commons-lang</ artifactId > < version >2.5</ version > </ dependency > < dependency > < groupId >commons-logging</ groupId > < artifactId >commons-logging</ artifactId > < version >1.1.1</ version > </ dependency > < dependency > < groupId >commons-pool</ groupId > < artifactId >commons-pool</ artifactId > < version >1.5.4</ version > </ dependency > < dependency > < groupId >cglib</ groupId > < artifactId >cglib</ artifactId > < version >2.2.2</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-aop</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-asm</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-beans</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < 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-context-support</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-core</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-expression</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-oxm</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-jdbc</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-tx</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-web</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-webmvc</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.slf4j</ groupId > < artifactId >slf4j-api</ artifactId > < version >1.5.8</ version > </ dependency > < dependency > < groupId >org.slf4j</ groupId > < artifactId >jcl-over-slf4j</ artifactId > < version >${org.slf4j.version}</ version > </ dependency > < dependency > < groupId >org.slf4j</ groupId > < artifactId >slf4j-log4j12</ artifactId > < version >${org.slf4j.version}</ version > </ dependency > < dependency > < groupId >log4j</ groupId > < artifactId >log4j</ artifactId > < version >1.2.14</ 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 > </ dependency > < dependency > < groupId >net.java.dev.rome</ groupId > < artifactId >rome</ artifactId > < version >1.0.0</ version > </ dependency > < dependency > < groupId >jdom</ groupId > < artifactId >jdom</ artifactId > < version >1.0</ version > </ dependency > < dependency > < groupId >org.codehaus.jackson</ groupId > < artifactId >jackson-core-asl</ artifactId > < version >${org.codehaus.jackson.version}</ version > </ dependency > < dependency > < groupId >org.codehaus.jackson</ groupId > < artifactId >jackson-mapper-asl</ artifactId > < version >${org.codehaus.jackson.version}</ version > </ dependency > < dependency > < groupId >javax.validation</ groupId > < artifactId >validation-api</ artifactId > < version >1.0.0.GA</ version > </ dependency > < dependency > < groupId >org.hibernate</ groupId > < artifactId >hibernate-validator</ artifactId > < version >4.2.0.Final</ version > </ dependency > < dependency > < groupId >javax.persistence</ groupId > < artifactId >persistence-api</ artifactId > < version >1.0.2</ version > </ dependency > < dependency > < groupId >org.hsqldb</ groupId > < artifactId >hsqldb</ artifactId > < version >2.2.7</ version > </ dependency > < dependency > < groupId >mysql</ groupId > < artifactId >mysql-connector-java</ artifactId > < version >5.1.18</ version > </ dependency > < dependency > < groupId >joda-time</ groupId > < artifactId >joda-time</ artifactId > < version >2.0</ version > </ dependency > </ dependencies > |
Plugin 설정
현재 M2Eclipse 버전에서 생성된 Maven 프로젝트는 기본적으로 JDK v1.5 로 설정이 되어있으며, 해당 버전을 JDK v1.6 으로 변경한 후 WTP (Web Tools Platform) 지원을 하기위하여 plugins 항목에 아래와 같이 설정을 합니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | < build > ~~~~~~~~~~~~~~~~~~~~ < plugins > < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-compiler-plugin</ artifactId > < version >2.3.2</ version > < configuration > < source >1.6</ source > < target >1.6</ target > < encoding >UTF-8</ encoding > </ configuration > </ plugin > < plugin > < artifactId >maven-eclipse-plugin</ artifactId > < version >2.9</ version > < configuration > < downloadSources >true</ downloadSources > < downloadJavadocs >true</ downloadJavadocs > < wtpversion >2.0</ wtpversion > </ configuration > </ plugin > </ plugins > ~~~~~~~~~~~~~~~~~~~~ </ build > |
전체 pom.xml 소스
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | < project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" < modelVersion >4.0.0</ modelVersion > < groupId >kr.co.beany</ groupId > < artifactId >sample-spring-webapp</ artifactId > < packaging >war</ packaging > < version >1.0.0</ version > < name >sample-spring-webapp Maven Webapp</ name > < properties > < project.build.sourceEncoding >UTF-8</ project.build.sourceEncoding > < org.springframework.version >3.1.1.RELEASE</ org.springframework.version > < org.slf4j.version >1.5.8</ org.slf4j.version > < org.codehaus.jackson.version >1.9.3</ org.codehaus.jackson.version > </ properties > < dependencies > < dependency > < groupId >junit</ groupId > < artifactId >junit</ artifactId > < version >3.8.1</ version > < scope >test</ scope > </ dependency > < dependency > < groupId >javax.servlet</ groupId > < artifactId >jstl</ artifactId > < version >1.2</ version > </ dependency > < dependency > < groupId >javax.servlet.jsp</ groupId > < artifactId >jsp-api</ artifactId > < version >2.2</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >javax.servlet</ groupId > < artifactId >javax.servlet-api</ artifactId > < version >3.0.1</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >taglibs</ groupId > < artifactId >standard</ artifactId > < version >1.1.2</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >aopalliance</ groupId > < artifactId >aopalliance</ artifactId > < version >1.0</ version > </ dependency > < dependency > < groupId >aspectj</ groupId > < artifactId >aspectjweaver</ artifactId > < version >1.5.4</ version > </ dependency > < dependency > < groupId >asm</ groupId > < artifactId >asm</ artifactId > < version >3.3.1</ version > </ dependency > < dependency > < groupId >commons-beanutils</ groupId > < artifactId >commons-beanutils</ artifactId > < version >1.8.0</ version > </ dependency > < dependency > < groupId >commons-dbcp</ groupId > < artifactId >commons-dbcp</ artifactId > < version >1.4</ version > </ dependency > < dependency > < groupId >commons-collections</ groupId > < artifactId >commons-collections</ artifactId > < version >3.2.1</ version > </ dependency > < dependency > < groupId >commons-digester</ groupId > < artifactId >commons-digester</ artifactId > < version >2.0</ version > </ dependency > < dependency > < groupId >commons-fileupload</ groupId > < artifactId >commons-fileupload</ artifactId > < version >1.2.2</ version > </ dependency > < dependency > < groupId >commons-lang</ groupId > < artifactId >commons-lang</ artifactId > < version >2.5</ version > </ dependency > < dependency > < groupId >commons-logging</ groupId > < artifactId >commons-logging</ artifactId > < version >1.1.1</ version > </ dependency > < dependency > < groupId >commons-pool</ groupId > < artifactId >commons-pool</ artifactId > < version >1.5.4</ version > </ dependency > < dependency > < groupId >cglib</ groupId > < artifactId >cglib</ artifactId > < version >2.2.2</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-aop</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-asm</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-beans</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < 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-context-support</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-core</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-expression</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-oxm</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-jdbc</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-tx</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-web</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-webmvc</ artifactId > < version >${org.springframework.version}</ version > </ dependency > < dependency > < groupId >org.slf4j</ groupId > < artifactId >slf4j-api</ artifactId > < version >1.5.8</ version > </ dependency > < dependency > < groupId >org.slf4j</ groupId > < artifactId >jcl-over-slf4j</ artifactId > < version >${org.slf4j.version}</ version > </ dependency > < dependency > < groupId >org.slf4j</ groupId > < artifactId >slf4j-log4j12</ artifactId > < version >${org.slf4j.version}</ version > </ dependency > < dependency > < groupId >log4j</ groupId > < artifactId >log4j</ artifactId > < version >1.2.14</ 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 > </ dependency > < dependency > < groupId >net.java.dev.rome</ groupId > < artifactId >rome</ artifactId > < version >1.0.0</ version > </ dependency > < dependency > < groupId >jdom</ groupId > < artifactId >jdom</ artifactId > < version >1.0</ version > </ dependency > < dependency > < groupId >org.codehaus.jackson</ groupId > < artifactId >jackson-core-asl</ artifactId > < version >${org.codehaus.jackson.version}</ version > </ dependency > < dependency > < groupId >org.codehaus.jackson</ groupId > < artifactId >jackson-mapper-asl</ artifactId > < version >${org.codehaus.jackson.version}</ version > </ dependency > < dependency > < groupId >javax.validation</ groupId > < artifactId >validation-api</ artifactId > < version >1.0.0.GA</ version > </ dependency > < dependency > < groupId >org.hibernate</ groupId > < artifactId >hibernate-validator</ artifactId > < version >4.2.0.Final</ version > </ dependency > < dependency > < groupId >javax.persistence</ groupId > < artifactId >persistence-api</ artifactId > < version >1.0.2</ version > </ dependency > < dependency > < groupId >org.hsqldb</ groupId > < artifactId >hsqldb</ artifactId > < version >2.2.7</ version > </ dependency > < dependency > < groupId >mysql</ groupId > < artifactId >mysql-connector-java</ artifactId > < version >5.1.18</ version > </ dependency > < dependency > < groupId >joda-time</ groupId > < artifactId >joda-time</ artifactId > < version >2.0</ version > </ dependency > </ dependencies > < build > < finalName >sample-spring-webapp</ finalName > < plugins > < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-war-plugin</ artifactId > < version >2.2</ version > < configuration > < warSourceDirectory >webapp</ warSourceDirectory > </ configuration > </ plugin > < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-compiler-plugin</ artifactId > < version >2.3.2</ version > < configuration > < source >1.6</ source > < target >1.6</ target > < encoding >UTF-8</ encoding > </ configuration > </ plugin > < plugin > < artifactId >maven-eclipse-plugin</ artifactId > < version >2.9</ version > < configuration > < downloadSources >true</ downloadSources > < downloadJavadocs >true</ downloadJavadocs > < wtpversion >2.0</ wtpversion > </ configuration > </ plugin > </ plugins > </ build > </ project > |
pom.xml 설정 적용
pom.xml 파일을 저장하신 후 프로젝트 명에서 마우스 오른쪽 버튼을 클릭한 후 Maven > Update Project Configuration (1) 을 클릭하여 M2Eclipse 의 Maven 프로젝트 설정을 업데이트 합니다.
Maven 프로젝트 설정이 정상적으로 적용이 되면 아래의 그림과 같이 JDK 버전이 JavaSE-1.6 으로 변경이 됩니다.
출처 : http://blog.beany.co.kr/archives/1068
'Server Enterprise > Gradle & Maven' 카테고리의 다른 글
[Gradle] cache 삭제 (0) | 2021.08.12 |
---|---|
[maven] 외부 jar 추가 (0) | 2016.10.26 |
[Maven] M2Eclipse project 생성 2 (0) | 2015.08.26 |
[Maven] M2Eclipse project 생성 1 (0) | 2015.08.26 |
[MAVEN] 설치 및 이클립스 연동 (0) | 2015.08.17 |