<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Sealyu

    --- 博客已遷移至: http://www.sealyu.com/blog

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks

    Procedure

    Prerequisites and Assumptions

    • Maven is already installed
    • A local instance of Tomcat is already installed and configured to run on port 8080
    • Optional - Eclipse is installed

    Step One - Prepare the Tomcat Manager application

    In order to deploy a web app to your Tomcat server, you will need to ensure that you can access the Tomcat Manager application at: http://localhost:8080/manager/html. Typically, you just need to ensure that your <tomcat>/conf/tomcat-users.xml file has the following defined:

    <?xml version='1.0' encoding='utf-8'?>
    <tomcat-users>
      <role rolename="manager"/>
      <role rolename="admin"/>
      <user username="admin" password="admin" roles="admin,manager"/>
    </tomcat-users>

    In this case, we will be logging in to the Tomcat Manager app using:

    username admin
    password admin
    ???Back to Top

    Step Two - Create a New Web App Using Maven

    Next, we will use a Maven archetype to generate a new web application project.

    Assuming that you will primarily use Eclipse as your IDE, you may wish to start the project within Eclipse. We'll start the project within Eclipse and then use Maven to fill the project in with the proper Maven web app structure.

    • In Eclipse create a new General project. New > Project... > General > Project
    • Project name: "sw" (name it what you wish, but remember to replace 'sw' with your project name in all instances where that appears in this document from here on out.)

    The steps above just create a General project in your Eclipse workspace (e.g. a folder with a .project settings file inside of it).

    Next, open a command prompt, cd into the 'sw' project directory, and then execute the following Maven command (all on one line):

    mvn archetype:create
       -DgroupId=com.burlesontech.sw
       -DartifactId=webapp
       -DarchetypeArtifactId=maven-archetype-webapp

    You project will now have the following structure:

    • sw
      • webapp
        • src
          • main
            • resources
            • webapp
              • WEB-INF
                • web.xml
              • index.jsp
        • pom.xml
      • .project

    In Eclipse, right-click on the project and select Refresh to see this stuff within Eclipse. (Note that the .project file will typically not appear within Eclipse, but it is there.)

    ???Back to Top

    Step Three - Define Your Tomcat Server in Maven Settings

    Open your Maven settings.xml file (e.g. C:"Documents and Settings"Administrator".m2"settings.xml) and add a server 'myserver' with the credentials for logging into the Tomcat Manager application:

    <settings>
        <servers>
        <server>
            <id>myserver</id>
            <username>admin</username>
            <password>admin</password>
        </server>
        </servers>
    ...
    ???Back to Top

    Step Four - Point Your Pom to Your Tomcat Server

    Open the pom.xml file in the 'sw' project and replace the <build> section so that it looks like this:

    <build>
        <finalName>sw</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <configuration>
                         <server>myserver</server>
                         <path>/sw</path>
                </configuration>
            </plugin>
        </plugins>
    </build>

    Here, we have added the Tomcat plugin for Maven. Note that the <configuration> section needs to point to the server you defined in settings.xml ('myserver'). The <finalName> and the <path> are used to tell the web context that you want to deploy to. In this case, we'll be able to access our application at http://localhost:8080/sw.

    ???Back to Top

    Step Five - Build and Deploy the Web App

    On a command prompt, you can now cd into the sw/webapp directory where the project pom exists. The execute the following command:

    mvn tomcat:deploy

    If you get a BUILD SUCCESSFUL message, you should then be able to access your web application at http://localhost:8080/sw/.

    You should see "Hello World!" in your web browser (from the index.jsp page). Now you're all set and ready to start building the next killer web app!

    If you try to deploy again with the same command, you will likely get a FAIL message because the application already exists at the path. For successive deployments, use the following command instead:

    mvn tomcat:redeploy

    Next, you may want to enable log4j logging for your new application; check out How to setup Log4j in a web app - fast.

    posted on 2010-01-08 13:46 seal 閱讀(1254) 評論(0)  編輯  收藏 所屬分類: Maven
    主站蜘蛛池模板: 亚洲精品成人片在线播放 | 亚洲人成亚洲精品| 久久久久亚洲国产AV麻豆 | 亚洲中文无码永久免| 免费精品一区二区三区第35| 免费jlzzjlzz在线播放视频| 亚洲乱码一二三四区麻豆| 一个人看的www免费视频在线观看 一个人免费视频观看在线www | 亚洲男人的天堂久久精品 | 美女视频黄a视频全免费| 亚洲成色WWW久久网站| 日韩在线视频线视频免费网站| 日韩av无码成人无码免费| 久久久无码精品亚洲日韩蜜桃| 免费中文字幕视频| 午夜老司机免费视频| 亚洲另类春色校园小说| 四虎影视在线影院在线观看免费视频| 亚洲无码日韩精品第一页| 亚洲hairy多毛pics大全| 免费下载成人电影| 久久亚洲中文字幕精品有坂深雪| 中文日本免费高清| 亚洲国模精品一区| 精品一区二区三区无码免费直播 | 亚洲三级在线视频| 亚洲免费网站在线观看| 亚洲爆乳无码专区| 三级网站免费观看| 久久亚洲精品无码播放| 人人爽人人爽人人片A免费| 国产精品免费一级在线观看| 亚洲综合小说另类图片动图| 青青视频观看免费99| 麻豆亚洲AV永久无码精品久久| 你懂的在线免费观看| 亚洲精品中文字幕乱码三区| A国产一区二区免费入口| 亚洲午夜AV无码专区在线播放| 日韩电影免费在线观看网址| 免费国产一级特黄久久|