• maven tomcat1.7环境下构建javaweb 项目


    • tomcat用户权限设置

    在tomcat安装路径conf目录下tomcat-users.xml添加:

    <role rolename="admin-gui"/>
    <role rolename="admin-script"/>
    <role rolename="manager-gui"/>
    <role rolename="manager-script"/>
    <role rolename="manager-jmx"/>
    <role rolename="manager-status"/>
    <user username="admin" password="password" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>
    • maven的server设置

    在maven安装路径conf目录下的setting.xml <servers>节点中添加:

    <server>
        <id>tomcat</id>
        <username>admin</username>
        <password>password</password>
    </server>
    • pom.xml设置

    在项目pom.xml中添加:

    <plugin>
         <groupId>org.apache.tomcat.maven</groupId>
         <artifactId>tomcat7-maven-plugin</artifactId>
         <version>2.2</version>
         <configuration>
                <!-- 注意此处的url -->
                <url>http://localhost:8080/manager/text</url>
                <server>tomcat</server> <!-- 此处的名字必须和setting.xml中配置的ID一致-->
                 <path>/projectname</path> <!-- 此处的名字是项目发布的工程名-->
                 <username>admin</username>
                 <password>password</password> 
         </configuration>
    </plugin>   

    如果项目默认的web目录为WebContent,则添加:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1.1</version>
        <configuration>
            <webResources>
                 <resource>
                       <directory>WebContent</directory>
                  </resource>
             </webResources>
        </configuration>
    </plugin>

    否则会报Error assembling WAR: webxml attribute is required (web.xml找不到)

    • 运行构建命令

    启动tomcat1.7(必须提前启动)

    两种方式:

    1、命令行:定位到项目根路径,第一次构建时运行 mvn tomcat:deploy,之后重新构建的时候运行 mvn tomcat:redeploy

    2、IDE(eclipse):选择项目右击,选择Run As->Maven bulid...  在弹出的窗口中找到 Goals,第一次构建时 填入tomcat:deploy 然后点击apply run,之后填入tomcat:redeploy 然后点击apply run

  • 相关阅读:
    树分治 poj 1741
    堆 poj 2010
    堆 poj 2442
    堆的基本操作
    状态压缩codeforces 11 D
    状态压缩 CSU1129 送货到家
    炮兵阵地 POJ 1185
    状态压缩 HDU4539 郑厂长系列故事——排兵布阵
    状态压缩 HDU 3182
    android手势创建及识别
  • 原文地址:https://www.cnblogs.com/verkey/p/5386939.html
Copyright © 2020-2023  润新知