ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [intelliJ] Spring mvc Project 초기 설정하기.
    Dev/개발환경 2019. 7. 13. 15:02

     

    1. Spring mvc로 프로젝트 생성

     

     

    2. Maven, Tomcat 설정,

      2-1 Run/Debug Configurations -> tomcat -> tomcat Path 입력 -> run start url '/' 로 변경


      2-1 프로젝트 오른쪽클릭 - add Fremework - Maven 추가 

        [이미지 없음]  [maven setting git]

     

     

    3. Spring 라이브러리 추가해주기 `Maven`

    <프로젝트 설정- maven으로 추가된 Spring .jar을 프로젝트로 Import>

     

     

    4. WEB.xml 설정해주기 (web.xml setting link)

    <web.xml 수정하기> - 추가적으로 UTF-8 인코딩 필터도 달아주면 좋다.

     

    4. Dispatcher-servlet.xml 수정하기 (Dispatcher-servlet.xml git link)

    <dispatcher-servlet.xml>- component-scan 부분에 들어갈 패키지명에 주의 하자.

    <?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:context="http://www.springframework.org/schema/context"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
      http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
    
    
    
    
    	<mvc:annotation-driven></mvc:annotation-driven> <!-- Annotation 활성화 -->
    	<context:component-scan base-package="Controller"></context:component-scan> <!-- Component 패키지 지정 -->
    
    	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="prefix" value="/WEB-INF/views/"></property> <!-- view 경로 -->
    		<property name="suffix" value=".jsp"></property>
    	</bean>
    
    
    </beans>

     

    6. Controller 만들어주고 `Dispatcher-servlet`에 component-scan을 해당 패키지 명으로 컨트롤러 만들어주기

     

    'Dev > 개발환경' 카테고리의 다른 글

    [Visual studio Code] 자주쓰는 플러그인  (0) 2019.07.14
    [Visual Studio] 자주쓰는 설정모음.  (0) 2019.07.14
Designed by Tistory.