码迷,mamicode.com
首页 > 其他好文 > 详细

使用maven的tomcat:run 部署tomcat

时间:2018-02-25 01:14:39      阅读:544      评论:0      收藏:0      [点我收藏+]

标签:fill   ati   mic   tags   tomcat8   log   script   textarea   bar   

项目结构:
技术分享图片

Maven工程没有Tomcat环境也能运行web工程:(pom.xml中)
    1, 配置tomcat-maven插件
  <build>
    <finalName>babasport</finalName>
    <!-- 添加tomcat插件,eclipse不用再配置tomcat运行环境.
         Run As-Maven build...-clean package 启动web页面
    -->
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <!-- 本地jdk版本 -->
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat8-maven-plugin</artifactId>
            <version>3.0-r1756463</version>
            <!-- 在package阶段启动web容器 -->
            <executions>
              <execution>
                      <!-- 打包阶段 -->
                    <phase>package</phase>
                    <!-- 运行目标 -->
                    <goals>
                        <goal>run</goal>
                    </goals>
              </execution>
          </executions>
        </plugin>
    </plugins>
  </build>
    
    2, 配置jsp ,servlet 等依赖
<!-- 配置jsp依赖 -->
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api -->
<dependency>
    <groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
    <groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/jsptags/pager-taglib -->
<dependency>
    <groupId>jsptags</groupId>
<artifactId>pager-taglib</artifactId>
<version>2.0</version>
<!--  -->
<scope>provided</scope>
</dependency>
 
1
<!-- 配置jsp依赖 -->
2
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api -->
3
<dependency>
4
    <groupId>javax.servlet.jsp</groupId>
5
<artifactId>jsp-api</artifactId>
6
<version>2.2</version>
7
<scope>provided</scope>
8
</dependency>
9
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
10
<dependency>
11
    <groupId>javax.servlet</groupId>
12
<artifactId>jstl</artifactId>
13
<version>1.2</version>
14
</dependency>
15
<!-- https://mvnrepository.com/artifact/jsptags/pager-taglib -->
16
<dependency>
17
    <groupId>jsptags</groupId>
18
<artifactId>pager-taglib</artifactId>
19
<version>2.0</version>
20
<!--  -->
21
<scope>provided</scope>
22
</dependency>

使用maven的tomcat:run 部署tomcat

标签:fill   ati   mic   tags   tomcat8   log   script   textarea   bar   

原文地址:https://www.cnblogs.com/lcs-java/p/8468027.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!