๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
SpringBoot

[SpringBoot] servlet-context.xml, root-context.xml, pom.xml, web.xml ์ฐจ์ด์ 

by ๊ฐœ๋ฐœLOG 2025. 1. 12.
๋ฐ˜์‘ํ˜•

1. root-context.xml์˜ ์—ญํ• 

root-context.xml์€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ „์ฒด์— ๊ณตํ†ต์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š” Bean์„ ์ •์˜ํ•˜๋Š” ์Šคํ”„๋ง ์„ค์ • ํŒŒ์ผ์ž…๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—๋Š” ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์„œ๋น„์Šค(@Service), ๋ฐ์ดํ„ฐ ์•ก์„ธ์Šค๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” DAO/Repository(@Repository), ๊ณตํ†ต์ ์ธ ์œ ํ‹ธ๋ฆฌํ‹ฐ ๋“ฑ์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

  • ์˜ˆ์‹œ:
    • ์„œ๋น„์Šค ๊ณ„์ธต (@Service)
    • ๋ฐ์ดํ„ฐ ์ ‘๊ทผ ๊ณ„์ธต (@Repository)
    • ์˜ˆ์™ธ ์ฒ˜๋ฆฌ, ๊ณตํ†ต ์ปดํฌ๋„ŒํŠธ๋“ค (@Component)

root-context.xml ์˜ˆ์‹œ :

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
		http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
	
	<!-- Root Context: defines shared resources visible to all other web components -->
		<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
		<!-- <property name="driverClassName" value="oracle.jdbc.OracleDriver" 
			/> <property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:XE" /> -->
		<property name="driverClassName"
			value="net.sf.log4jdbc.sql.jdbcapi.DriverSpy" />
		<property name="jdbcUrl"
			value="jdbc:log4jdbc:oracle:thin:@localhost:1521:XE" />
		<property name="username" value="c1" />
		<property name="password" value="c1" />
	</bean>

	<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource"
		destroy-method="close">
		<constructor-arg ref="hikariConfig" />
	</bean>

	<bean id="sqlSessionFactory"
		class="org.mybatis.spring.SqlSessionFactoryBean" primary="false">
		<property name="dataSource" ref="dataSource"></property>
	</bean>

	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"></property>
	</bean>
	
	<mybatis-spring:scan base-package="com.cocoa.mapper" />	
	<context:component-scan base-package="com.cocoa.service"></context:component-scan>
</beans>

2. servlet-context.xml์˜ ์—ญํ• 

servlet-context.xml์€ Spring Web MVC ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์›น ๊ด€๋ จ ์„ค์ •์„ ์ฒ˜๋ฆฌํ•˜๋Š” ํŒŒ์ผ์ž…๋‹ˆ๋‹ค. ์ด ํŒŒ์ผ์€ DispatcherServlet์— ์˜ํ•ด ๋กœ๋“œ๋˜๊ณ , ์ฃผ๋กœ ์›น ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์ปจํŠธ๋กค๋Ÿฌ, ๋ทฐ ๋ฆฌ์กธ๋ฒ„, ๋ฆฌ์†Œ์Šค ํ•ธ๋“ค๋ง ๋“ฑ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. @Controller๊ฐ€ ๋ถ™์€ ํด๋ž˜์Šค๋“ค์„ ์Šค์บ”ํ•˜๋Š” ๊ฒƒ๋„ ์ด ํŒŒ์ผ์—์„œ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

  • ์˜ˆ์‹œ:
    • ์ปจํŠธ๋กค๋Ÿฌ (@Controller)
    • ๋ทฐ ๋ฆฌ์กธ๋ฒ„: JSP ๋ทฐ๋ฅผ ์„ค์ •ํ•˜๊ฑฐ๋‚˜, ํ…œํ”Œ๋ฆฟ ์—”์ง„์„ ์„ค์ •ํ•˜๋Š” ๋ถ€๋ถ„
    • ์ •์  ๋ฆฌ์†Œ์Šค ์ฒ˜๋ฆฌ: /resources/**์™€ ๊ฐ™์€ ์ •์  ํŒŒ์ผ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ถ€๋ถ„
    • Spring MVC ํŠนํ™” ์„ค์ •: @Controller ๊ธฐ๋ฐ˜์˜ ์š”์ฒญ ์ฒ˜๋ฆฌ

servlet-context.xml ์˜ˆ์‹œ :

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:beans="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd
		http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">

	<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
	
	<!-- Enables the Spring MVC @Controller programming model -->
	<annotation-driven />

	<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
	<resources mapping="/resources/**" location="/resources/" />

	<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
	<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<beans:property name="prefix" value="/WEB-INF/views/" />
		<beans:property name="suffix" value=".jsp" />
	</beans:bean>
	
	<context:component-scan base-package="com.cocoa.controller" />
	<context:component-scan base-package="com.cocoa.exception" />
	
	
</beans:beans>

 

3. ์ปจํŠธ๋กค๋Ÿฌ์™€ ์˜ˆ์™ธ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์™œ servlet-context.xml์— ๋„ฃ๋Š”๊ฐ€?

@Controller์™€ ๊ด€๋ จ๋œ ์„ค์ •์€ ์›น ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ถ€๋ถ„์ด๊ธฐ ๋•Œ๋ฌธ์— servlet-context.xml์—์„œ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์ด ์ ์ ˆํ•ฉ๋‹ˆ๋‹ค. root-context.xml์—์„œ๋Š” ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์ด๋‚˜ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ์™€ ๊ด€๋ จ๋œ Bean๋“ค์ด ์ •์˜๋˜์ง€๋งŒ, ์‹ค์ œ HTTP ์š”์ฒญ์„ ๋ฐ›์•„์„œ ์ฒ˜๋ฆฌํ•˜๋Š” ์ปจํŠธ๋กค๋Ÿฌ๋Š” ์›น ๊ด€๋ จ ์„ค์ •์ด๋ฏ€๋กœ servlet-context.xml์— ์ •์˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 


 

4. web.xml (์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ฐฐํฌ ์„ค๋ช…์ž)์˜ ์—ญํ• 

web.xml์€ ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๋ฐฐํฌ ์„ค๋ช…์ž(Deployment Descriptor)๋กœ, ์„œ๋ธ”๋ฆฟ ์ปจํ…Œ์ด๋„ˆ(์˜ˆ: Tomcat)์™€ Spring ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐ„์˜ ์„ค์ •๊ณผ ์ดˆ๊ธฐํ™”๋ฅผ ๋‹ด๋‹นํ•ฉ๋‹ˆ๋‹ค. ์ฃผ๋กœ ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์„ค์ •, ์„œ๋ธ”๋ฆฟ ๋งคํ•‘, ๋ฆฌ์Šค๋„ˆ ๋“ฑ๋ก ๋“ฑ๊ณผ ๊ด€๋ จ๋œ ์ •๋ณด๋ฅผ ๋‹ด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

์ฃผ์š” ์—ญํ• :

  • DispatcherServlet ์„ค์ •: DispatcherServlet์€ Spring MVC์—์„œ ์›น ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์ค‘์•™ ์„œ๋ธ”๋ฆฟ์ž…๋‹ˆ๋‹ค. web.xml์—์„œ DispatcherServlet์„ ์„ค์ •ํ•˜์—ฌ ์š”์ฒญ์ด DispatcherServlet์œผ๋กœ ์ „๋‹ฌ๋˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.
  • ์„œ๋ธ”๋ฆฟ ๋งคํ•‘: DispatcherServlet์ด ์–ด๋–ค URL ํŒจํ„ด์„ ์ฒ˜๋ฆฌํ• ์ง€ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ๋ณดํ†ต / ๋˜๋Š” /app/* ๋“ฑ์œผ๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
  • ๋ฆฌ์Šค๋„ˆ ๋“ฑ๋ก: ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์‹œ์ž‘๊ณผ ์ข…๋ฃŒ ์‹œ ์ˆ˜ํ–‰ํ•  ์ž‘์—…์„ ์ •์˜ํ•˜๋Š” ๋ฆฌ์Šค๋„ˆ๋ฅผ ๋“ฑ๋กํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, Spring์˜ ContextLoaderListener๋Š” ApplicationContext๋ฅผ ์ดˆ๊ธฐํ™”ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
  • ํ•„ํ„ฐ ์„ค์ •: ์›น ์š”์ฒญ์— ๋Œ€ํ•œ ํ•„ํ„ฐ๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, CharacterEncodingFilter๋‚˜ EncodingFilter ๋“ฑ์€ ์š”์ฒญ์˜ ๋ฌธ์ž ์ธ์ฝ”๋”ฉ์„ ์„ค์ •ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
  • ๊ธฐํƒ€ ์„œ๋ธ”๋ฆฟ, ํ•„ํ„ฐ, ๋ฆฌ์Šค๋„ˆ ์„ค์ •: ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ํ•„์š”ํ•œ ๋‹ค๋ฅธ ์„œ๋ธ”๋ฆฟ์ด๋‚˜ ํ•„ํ„ฐ๋“ค์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

web.xml ์˜ˆ์‹œ :

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee https://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

	<!-- The definition of the Root Spring Container shared by all Servlets 
		and Filters -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/spring/root-context.xml</param-value>
	</context-param>

	<!-- Creates the Spring Container shared by all Servlets and Filters -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<!-- Processes application requests -->
	<servlet>
		<servlet-name>appServlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>appServlet</servlet-name>
		<url-pattern>/</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>
		<init-param>
			<param-name>forceEncoding</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>encodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

</web-app>

 

 

5. pom.xml (Maven ํ”„๋กœ์ ํŠธ ์„ค์ • ํŒŒ์ผ)์˜ ์—ญํ• 

pom.xml์€ Maven ๋นŒ๋“œ ๋„๊ตฌ์˜ ํ”„๋กœ์ ํŠธ ๊ฐ์ฒด ๋ชจ๋ธ(POM) ํŒŒ์ผ์ž…๋‹ˆ๋‹ค. ์ด ํŒŒ์ผ์€ ํ”„๋กœ์ ํŠธ์˜ ๋นŒ๋“œ ์„ค์ •, ์ข…์†์„ฑ ๊ด€๋ฆฌ, ํ”Œ๋Ÿฌ๊ทธ์ธ ์„ค์ • ๋“ฑ์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค. pom.xml์€ Maven์„ ์‚ฌ์šฉํ•˜์—ฌ ํ”„๋กœ์ ํŠธ๋ฅผ ๋นŒ๋“œํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š” ๋ฐ ํ•„์ˆ˜์ ์ž…๋‹ˆ๋‹ค.

์ฃผ์š” ์—ญํ• :

  • ์ข…์†์„ฑ ๊ด€๋ฆฌ: ํ”„๋กœ์ ํŠธ๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์™€ ๊ทธ ๋ฒ„์ „์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, Spring Framework, MyBatis, JPA ๋“ฑ๊ณผ ๊ฐ™์€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์˜ ๋ฒ„์ „ ์ •๋ณด๋ฅผ ์„ค์ •ํ•˜์—ฌ Maven์ด ์ž๋™์œผ๋กœ ํ•ด๋‹น ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋“ค์„ ๋‹ค์šด๋กœ๋“œํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.
  • ๋นŒ๋“œ ์„ค์ •: ์ปดํŒŒ์ผ, ํŒจํ‚ค์ง•, ํ…Œ์ŠคํŠธ ๋“ฑ์˜ ๋นŒ๋“œ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค. Maven ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ํ†ตํ•ด ์ž๋™ํ™”๋œ ๋นŒ๋“œ ํ”„๋กœ์„ธ์Šค๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ํ”„๋กœํŒŒ์ผ ์„ค์ •: ๋‹ค์–‘ํ•œ ํ™˜๊ฒฝ์— ๋งž๋Š” ๋นŒ๋“œ ์„ค์ •์„ ์ •์˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ๊ฐœ๋ฐœ, ํ…Œ์ŠคํŠธ, ๋ฐฐํฌ ํ™˜๊ฒฝ์— ๋งž๋Š” ์„ค์ •์„ ์ œ๊ณตํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ํ”Œ๋Ÿฌ๊ทธ์ธ ์„ค์ •: Maven ๋นŒ๋“œ ๊ณผ์ •์—์„œ ์‚ฌ์šฉํ•  ํ”Œ๋Ÿฌ๊ทธ์ธ(์˜ˆ: maven-compiler-plugin, maven-war-plugin ๋“ฑ)์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ํ”„๋กœ์ ํŠธ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ๊ด€๋ฆฌ: ํ”„๋กœ์ ํŠธ์˜ ์ด๋ฆ„, ๋ฒ„์ „, ๋ผ์ด์„ผ์Šค, ๊ฐœ๋ฐœ์ž ์ •๋ณด ๋“ฑ์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

pom.xml ์˜ˆ์‹œ :

<?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.zerock</groupId>
	<artifactId>controller</artifactId>
	<name>ex02</name>
	<packaging>war</packaging>
	<version>1.0.0-BUILD-SNAPSHOT</version>
	<properties>
		<java-version>11</java-version>
		<org.springframework-version>5.0.7.RELEASE</org.springframework-version>
		<org.aspectj-version>1.9.6</org.aspectj-version>
		<org.slf4j-version>1.7.25</org.slf4j-version>
	</properties>
	<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>
		<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<version>${org.springframework-version}</version>
			<scope>test</scope>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
			<version>${org.springframework-version}</version>
		</dependency>

		<!-- AspectJ -->
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjrt</artifactId>
			<version>${org.aspectj-version}</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjweaver</artifactId>
			<version>${org.aspectj-version}</version>
			<!-- <scope>runtime</scope> -->
		</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.17</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>javax.servlet-api</artifactId>
			<version>3.1.0</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.12</version>
			<scope>test</scope>
		</dependency>

		<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<version>1.18.24</version>
			<scope>provided</scope>
		</dependency>

		<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis</artifactId>
			<version>3.5.6</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis-spring</artifactId>
			<version>1.3.2</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.zaxxer/HikariCP -->
		<dependency>
			<groupId>com.zaxxer</groupId>
			<artifactId>HikariCP</artifactId>
			<version>2.7.8</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.bgee.log4jdbc-log4j2/log4jdbc-log4j2-jdbc4 -->
		<dependency>
			<groupId>org.bgee.log4jdbc-log4j2</groupId>
			<artifactId>log4jdbc-log4j2-jdbc4</artifactId>
			<version>1.16</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc8 -->
		<dependency>
			<groupId>com.oracle.database.jdbc</groupId>
			<artifactId>ojdbc8</artifactId>
			<version>19.3.0.0</version>
		</dependency>

		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>2.14.2</version>
		</dependency>

		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml -->
		<dependency>
			<groupId>com.fasterxml.jackson.dataformat</groupId>
			<artifactId>jackson-dataformat-xml</artifactId>
			<version>2.14.2</version>
		</dependency>

		<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
		<dependency>
			<groupId>com.google.code.gson</groupId>
			<artifactId>gson</artifactId>
			<version>2.8.9</version>
		</dependency>

		<!-- https://mvnrepository.com/artifact/net.coobird/thumbnailator -->
		<dependency>
			<groupId>net.coobird</groupId>
			<artifactId>thumbnailator</artifactId>
			<version>0.4.8</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>11</source>
					<target>11</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>

 


6. ์ •๋ฆฌ:

  • root-context.xml: ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ํ•ต์‹ฌ Bean(์„œ๋น„์Šค, ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ๋“ฑ)๊ณผ ๊ณตํ†ต์ ์ธ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
  • servlet-context.xml: Spring Web MVC ๊ด€๋ จ ์„ค์ •์„ ์ฒ˜๋ฆฌํ•˜๋Š” ํŒŒ์ผ๋กœ, @Controller์™€ ๊ด€๋ จ๋œ Bean์„ ์ •์˜ํ•˜๊ณ , ์›น ์š”์ฒญ ์ฒ˜๋ฆฌ, ๋ทฐ ๋ฆฌ์กธ๋ฒ„ ๋“ฑ ์›น ๊ด€๋ จ ์„ค์ •์„ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.
  •  
  • web.xml: ์„œ๋ธ”๋ฆฟ, ๋ฆฌ์Šค๋„ˆ, ํ•„ํ„ฐ ๋“ฑ์˜ ์›น ๊ด€๋ จ ์„ค์ •์„ ๋‹ด๋‹นํ•ฉ๋‹ˆ๋‹ค. DispatcherServlet๊ณผ ContextLoaderListener ๋“ฑ์˜ ์„ค์ •์ด ํฌํ•จ๋ฉ๋‹ˆ๋‹ค.
  • pom.xml: ํ”„๋กœ์ ํŠธ์˜ ์ข…์†์„ฑ ๊ด€๋ฆฌ์™€ ๋นŒ๋“œ ์„ค์ •์„ ๋‹ด๋‹นํ•ฉ๋‹ˆ๋‹ค. Maven์„ ํ†ตํ•ด ํ•„์š”ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ, ๋นŒ๋“œ ํ”Œ๋Ÿฌ๊ทธ์ธ ๋“ฑ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
๋ฐ˜์‘ํ˜•