MyEclipse中用Maven建立Web項目

來源:互聯網
上載者:User

標籤:

MyEclipse中用Maven建立Web項目

工具/原料 
  • MyEclipse2014
  • Maven-3.3.3
方法/步驟 
  1. 1

    new --> other

  2. 2

    1、Wizards: mvaen

    2、Maven Project

    3、Next

  3. 3

    Use Default Workspace Location

  4. 4

    1、webapp

    2、maven-archetype-webapp

    3、next

  5. 5

    1、輸入Group Id

    2、輸入Artifact Id

    3、Finish

  6. 6

    這時候會看到檔案報錯,解決辦法

    在Pom中添加Servlet

        <dependency>

          <groupId>javax.servlet</groupId>

          <artifactId>javax.servlet-api</artifactId>

          <version>3.0.1</version>

        </dependency>

    添加完成之後Ctrl+S儲存

  7. 7

    Junit版本修改 及  Servlet 只在編譯和測試時運行

        <dependency>

          <groupId>junit</groupId>

          <artifactId>junit</artifactId>

          <version>4.10</version>

          <scope>test</scope>

        </dependency>

        <dependency>

          <groupId>javax.servlet</groupId>

          <artifactId>javax.servlet-api</artifactId>

          <version>3.0.1</version>

          <!-- 只在編譯和測試時運行 -->

          <scope>provided</scope>

        </dependency>

  8. 8

    可以看出Maven項目不全

    下面是補全項目的方法

    1、選中項目,單擊滑鼠右鍵 New-->Folder

    src/main/java

    src/test/java

    2、選中項目,單擊滑鼠右鍵 New-->Source Folder

    src/test/resources

  9. 9

    項目檢查    檢查輸出路徑

  10. 10

    轉換成Web項目

  11. 11

    刪除不需要的輸出檔案

  12. 12

    項目建立完成

    END
方法 在Jetty容器中運行 
  1. 修改POM.XML

        <plugins>

          <plugin>

            <groupId>org.mortbay.jetty</groupId>

            <artifactId>jetty-maven-plugin</artifactId>

            <version>8.1.16.v20140903</version>

          </plugin>

        </plugins>

  2. 運行Jetty

    1、Run As  -->  Maven Build

  3. 在瀏覽器中輸入  本地地址及連接埠

    http://127.0.0.1:8080/

MyEclipse中用Maven建立Web項目

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.