在 Eclipse 下用 Gradle 構建 Web Application

來源:互聯網
上載者:User

標籤:

.建立一個 Dynamic Web Project, 在項目根目錄下建立 build.gradle 檔案, 並向其中寫入如下內容: 

import org.gradle.plugins.ide.eclipse.model.Facet  apply plugin: ‘java‘apply plugin: ‘war‘apply plugin: ‘eclipse-wtp‘  sourceCompatibility = 1.7   // 設定 JDK 版本webAppDirName = ‘WebContent‘    // 設定 WebApp 根目錄sourceSets.main.java.srcDir ‘src‘   // 設定 Java 源碼所在目錄  // 設定 maven 庫地址repositories {     mavenCentral() // 中央庫    // maven { url ‘<a href="http://maven.oschina.net/content/groups/public/‘ " target="_blank">http://maven.oschina.net/content/groups/public/‘ </a>} // 自訂庫地址}  // 設定依賴dependencies {    providedCompile ‘javax.servlet:servlet-api:2.5‘ // 編譯期    providedRuntime ‘javax.servlet:jstl:1.2‘    // 運行時}  // 設定 Project Facetseclipse {    wtp {        facet {            facet name: ‘jst.web‘, type: Facet.FacetType.fixed            facet name: ‘wst.jsdt.web‘, type: Facet.FacetType.fixed            facet name: ‘jst.java‘, type: Facet.FacetType.fixed            facet name: ‘jst.web‘, version: ‘3.0‘            facet name: ‘jst.java‘, version: ‘1.7‘            facet name: ‘wst.jsdt.web‘, version: ‘1.0‘        }    }}

  

2.接下來在項目上右擊 -> configure -> convert to Gradle project

3.再次在項目上右擊 -> Gradle -> Refresh All

4.如果沒有 web.xml 檔案的話, 再右擊項目 -> Java EE Tools -> Generate Deployment Descriptor Stub

5.最後看下效果如何, 在 WebContent 下建立 index.jsp 裡面隨便寫點什麼, 然後項目上右擊 -> Run As -> Run on Server

在 Eclipse 下用 Gradle 構建 Web Application

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.