Spring 개발 - BIS(Bus Information System) 만들기(1) - 구성 및 주변 구성
2018. 10. 6. 17:45 - 개발 새발
본 내용은 혼자서 공부하기 위한 용도로 사용된 것으로 비효율적일 수 있으며 실용적이지 않을 수 있습니다.
1. 개발 환경
- JDK 9.0.1
- Eclipse : Oxygen2
- Tomcat : 9.0.2
- Maven : 3.5.2
혹시나 개발 환경을 구성하는 방법이 궁금하거나 할 시에는 해당 게시물을 보고 따라하시면 됩니다.
(굳이 똑같은 버전이 아니더라도 상관없습니다.)
2017/12/22 - [코딩/Spring] - Spring 개발 - 게시판 만들기(1) - 개발환경 설치 및 구성, 이클립스 플러그인 설치
2. 디렉토리 구성
디렉토리는 다음과 같이 구성하였으며 대체적으로는 게시판 개발 때와 비슷하다.
* Maven 파일(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 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | <? 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" < modelVersion >4.0.0</ modelVersion > < groupId >com.gebalstory</ groupId > < artifactId >gcbus</ artifactId > < name >GCBus</ name > < packaging >war</ packaging > < version >1.0.0-BUILD-SNAPSHOT</ version > < properties > < java-version >1.7</ java-version > < org.springframework-version >3.2.8.RELEASE</ org.springframework-version > < org.slf4j-version >1.6.6</ org.slf4j-version > < org.aspectj-version >1.8.0</ org.aspectj-version > </ properties > < repositories > < repository > < id >egovframe</ id > < releases > < enabled >true</ enabled > </ releases > < snapshots > < enabled >false</ enabled > </ snapshots > </ repository > </ repositories > < dependencies > < dependency > < groupId >egovframework.rte</ groupId > < artifactId >egovframework.rte.ptl.mvc</ artifactId > < version >2.7.0</ version > </ dependency > <!-- 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 > <!-- xpp(xml parser) --> < dependency > < groupId >xpp3</ groupId > < artifactId >xpp3</ artifactId > < version >1.1.4c</ version > </ dependency > <!-- JSON <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib-ext-spring</artifactId> <version>1.0.2</version> </dependency> --> < dependency > < groupId >com.fasterxml.jackson.core</ groupId > < artifactId >jackson-core</ artifactId > < version >2.8.8</ version > </ dependency > < dependency > < groupId >com.fasterxml.jackson.core</ groupId > < artifactId >jackson-annotations</ artifactId > < version >2.8.8</ version > </ dependency > < dependency > < groupId >com.fasterxml.jackson.core</ groupId > < artifactId >jackson-databind</ artifactId > < version >2.8.8</ version > </ dependency > <!-- MappingJacksonJsonView --> < dependency > < groupId >org.codehaus.jackson</ groupId > < artifactId >jackson-mapper-asl</ artifactId > < version >1.9.13</ version > </ dependency > < dependency > < groupId >org.codehaus.jackson</ groupId > < artifactId >jackson-core-asl</ artifactId > < version >1.9.13</ 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.springframework</ groupId > < artifactId >spring-aop</ 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-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-jdbc</ artifactId > < version >${org.springframework-version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-tx</ artifactId > < version >${org.springframework-version}</ version > </ dependency > <!-- AspectJ --> < dependency > < groupId >org.aspectj</ groupId > < artifactId >aspectjrt</ artifactId > < version >${org.aspectj-version}</ version > </ dependency > < dependency > < groupId >org.aspectj</ groupId > < artifactId >aspectjweaver</ artifactId > < version >${org.aspectj-version}</ version > </ dependency > < dependency > < groupId >org.aspectj</ groupId > < artifactId >aspectjtools</ artifactId > < version >${org.aspectj-version}</ version > </ dependency > <!-- cglib --> < dependency > < groupId >cglib</ groupId > < artifactId >cglib</ artifactId > < version >2.2</ version > </ dependency > <!-- AOP Alliance --> < dependency > < groupId >aopalliance</ groupId > < artifactId >aopalliance</ artifactId > < version >1.0</ version > </ dependency > <!-- MyBatis --> < dependency > < groupId >org.mybatis</ groupId > < artifactId >mybatis</ artifactId > < version >3.2.2</ version > </ dependency > < dependency > < groupId >org.mybatis</ groupId > < artifactId >mybatis-spring</ artifactId > < version >1.2.0</ version > </ dependency > <!-- DBCP --> < dependency > < groupId >org.apache.tomcat</ groupId > < artifactId >tomcat-dbcp</ artifactId > < scope >provided</ scope > < version >7.0.53</ version > </ dependency > < dependency > < groupId >commons-dbcp</ groupId > < artifactId >commons-dbcp</ artifactId > < version >1.4</ version > </ dependency > <!-- MySql --> < dependency > < groupId >mysql</ groupId > < artifactId >mysql-connector-java</ artifactId > < version >5.1.31</ version > </ dependency > <!-- Logging --> < 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 > </ 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 > < dependency > < groupId >javax.annotation</ groupId > < artifactId >jsr250-api</ artifactId > < version >1.0</ version > </ dependency > <!-- MultipartHttpServletRequset --> < dependency > < groupId >commons-io</ groupId > < artifactId >commons-io</ artifactId > < version >2.0.1</ version > </ dependency > < dependency > < groupId >commons-fileupload</ groupId > < artifactId >commons-fileupload</ artifactId > < version >1.2.2</ version > </ dependency > <!-- Apache Codec --> < dependency > < groupId >commons-codec</ groupId > < artifactId >commons-codec</ artifactId > < version >1.10</ version > </ dependency > <!-- Test --> < dependency > < groupId >junit</ groupId > < artifactId >junit</ artifactId > < version >4.7</ version > < scope >test</ scope > </ 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 > |
메이븐 구성은 전 게시판과 비슷하나 xml parser 기능을 추가하였다.(전자정부 프레임의 경우 페이징 기능이 쓰일 수 있어서)
*서블릿 구성(web.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 | <? xml version = "1.0" encoding = "UTF-8" ?> xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version = "2.5" > < welcome-file-list > < welcome-file >/WEB-INF/jsp/node_find.jsp</ welcome-file > </ welcome-file-list > < context-param > < param-name >contextConfigLocation</ param-name > < param-value >classpath*:config/spring/context-*.xml</ param-value > </ context-param > < listener > < listener-class >org.springframework.web.context.ContextLoaderListener</ listener-class > </ listener > < servlet > < servlet-name >action</ servlet-name > < servlet-class >org.springframework.web.servlet.DispatcherServlet</ servlet-class > < init-param > < param-name >contextConfigLocation</ param-name > < param-value >/WEB-INF/config/*-servlet.xml</ param-value > </ init-param > < load-on-startup >1</ load-on-startup > </ servlet > < servlet-mapping > < servlet-name >action</ servlet-name > < url-pattern >*.do</ url-pattern > </ servlet-mapping > < filter > < filter-name >encodingFilter</ filter-name > < filter-class > org.springframework.web.filter.CharacterEncodingFilter </ filter-class > < init-param > < param-name >encoding</ param-name > < param-value >utf-8</ param-value > </ init-param > </ filter > < filter-mapping > < filter-name >encodingFilter</ filter-name > < url-pattern >*.do</ url-pattern > </ filter-mapping > </ web-app > |
*서블릿 구성(action-servlet.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 | <? xml version = "1.0" encoding = "UTF-8" ?> xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> < context:component-scan base-package = "com.gebalstory.gcbus" use-default-filters = "false" > < context:include-filter type = "annotation" expression = "org.springframework.stereotype.Controller" /> </ context:component-scan > < mvc:annotation-driven > < mvc:argument-resolvers > < bean class = "com.gebalstory.gcbus.common.resolver.CustomMapArgumentResolver" /> </ mvc:argument-resolvers > </ mvc:annotation-driven > < aop:aspectj-autoproxy /> < bean id = "loggerAspect" class = "com.gebalstory.gcbus.common.logger.LoggerAspect" /> < mvc:interceptors > < mvc:interceptor > < mvc:mapping path = "/**" /> < bean id = "loggerInterceptor" class = "com.gebalstory.gcbus.common.logger.LoggerInterceptor" ></ bean > </ mvc:interceptor > < mvc:interceptor > < mvc:mapping path = "/reg/**" /> < bean id = "adminInterceptor" class = "com.gebalstory.gcbus.common.interceptor.AdminInterceptor" ></ bean > </ mvc:interceptor > </ mvc:interceptors > < bean class = "org.springframework.web.servlet.view.BeanNameViewResolver" p:order = "0" /> < bean class = "org.springframework.web.servlet.view.json.MappingJacksonJsonView" id = "jsonView" > < property name = "contentType" value = "application/json; charset=UTF-8" /> </ bean > < bean class = "org.springframework.web.servlet.view.UrlBasedViewResolver" p:order = "1" p:viewClass = "org.springframework.web.servlet.view.JstlView" p:prefix = "/WEB-INF/jsp/" p:suffix = ".jsp" > </ bean > </ beans > |
서블릿 구성은 게시판 개발 할 때와 동일하다.
이외에 동일하게 짜여진 코드는 따로 파일을 첨부.
다음 포스팅에서 중요한 부분부터 다루겠다.
'코딩 > Spring' 카테고리의 다른 글
Spring 개발 - BIS(Bus Information System) 만들기(3) - 다음 지도 API(클릭 이벤트) (0) | 2018.10.07 |
---|---|
Spring 개발 - BIS(Bus Information System) 만들기(2) - 다음 지도 API 적용 시키기 (0) | 2018.10.07 |
Spring 개발 - BIS(Bus Information System) 만들기(0) (0) | 2018.10.06 |
Spring 개발 - 게시판 만들기 번외(3) - 회원 기능(로그인) (2) | 2018.03.13 |
Spring 개발 - 게시판 만들기 번외(2) - 회원 기능(회원가입) (0) | 2018.03.13 |