본문 바로가기

개발(합니다)/Java&Spring

Spring maven project에서 tomcat 실행하기

반응형

Spring maven project로 Spring framework를 하나씩 학습 내용을 정리합니다.

Tomcat 실행 하는 방법을 정리합니다.




1. spring maven 프로젝트 생성



2. pom.xml build 추가

    <build>
        <!-- <finalName>${project.artifactId}</finalName> -->

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.5</version>
            </plugin>

            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <ignorePackaging>true</ignorePackaging>
                    <!-- <url>http://localhost:9090/manager</url>
                    <server>Tomcat</server>
                    <path>/</path> -->
                </configuration>
            </plugin>
        </plugins>
    </build>


3. index.jsp 생성 및 작성



<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
    hello
</body>
</html>


4. web.xml 생성 및 작성



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

    <display-name>TestMavenWebPorject</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

</web-app>


5. run - maven build.. - goals=clean tomcat7:run




6. 웹브라우저 localhost:8080 실행



반응형