转载地址:http://ask.android-studio.org/?/article/8

This chapter is a work in progress.这一章是一项正在进行中的工作。

This chapter introduces the Gradle support for web applications. Gradle provides two plugins for web application development: the War plugin and the Jetty plugin. The War plugin extends the Java plugin to build a WAR file for your project. The Jetty plugin extends the War plugin to allow you to deploy your web application to an embedded Jetty web container.
<翻译>这一章介绍Gradle对网络应用的支持。Gradle为网络应用开发提供了2个插件:War和Jetty。War继承自Java,为你的项目构建一个War文件。Jetty继承自War,允许你部署你的网络应用到一个嵌入式Jetty网络容器。

10.1. Building a WAR file 构建一个War文件

To build a WAR file, you apply the War plugin to your project:
<翻译>如果想要构建一个War文件,你需要在你的项目中应用War插件

Example 10.1. War plugin 
<翻译>例 10.1.War插件

build.gradle
apply plugin: 'war'

Note: The code for this example can be found at samples/webApplication/quickstart which is in both the binary and source distributions of Gradle.
This also applies the Java plugin to your project. Running gradle build will compile, test and WAR your project. Gradle will look for the source files to include in the WAR file in src/main/webapp. Your compiled classes and their runtime dependencies are also included in the WAR file, in the WEB-INF/classes and WEB-INF/lib directories, respectively.
<翻译>笔记:例子的代码可以在Gradle的二进制和源分布文件的samples/webApplication/quickstart中找到。同时也需要在你的项目中应用Java插件。运行gradle build命令将编译,测试和打包(War包)你的项目。gradle将查找源文件放到war文件的src/main/webapp路径下。你编译的类和它们运行时的依赖文件也会分别放到war文件的WEB-INF/classes和WEB-INF/lib路径下。

Groovy web applications Groovy网络应用

You can combine multiple plugins in a single project, so you can use the War and Groovy plugins together to build a Groovy based web application. The appropriate Groovy libraries will be added to the WAR file for you.
<翻译>你能够在一个项目中结合多个插件,所以你可以同时使用War和Groovy构建一个基于Groovy的网络应用

10.2. Running your web application 运行你的网络应用

To run your web application, you apply the Jetty plugin to your project:
<翻译>如果想要运行你的网络应用,你需要在你的项目中应用Jetty插件。

Example 10.2. Running web application with Jetty plugin 
<翻译>例 10.2.使用Jetty插件运行网络应用

build.gradle
apply plugin: 'jetty'

This also applies the War plugin to your project. Running gradle jettyRun will run your web application in an embedded Jetty web container. Running gradle jettyRunWar will build the WAR file, and then run it in an embedded web container.
<翻译>这里同样需要在你的项目中应用War插件。运行gradle jettyRun命令将在一个嵌入式Jetty玩了容器中运行你的网络应用。运行gradle jettyRunWar命令将构建War文件,接着在一个嵌入式Jetty玩了容器中运行你的网络应用。

TODO: which url, configure port, uses source files in place and can edit your files and reload.
<翻译> TODO:哪个url,配置端口,使用源文件并编辑和重载你的文件。

10.3. Summary 摘要

You can find out more about the War plugin in Chapter 26, The War Plugin and the Jetty plugin in Chapter 28, The Jetty Plugin. You can find more sample Java projects in the samples/webApplication directory in the Gradle distribution.
<翻译>你可以在第二十六章中发现更多关于War插件的说明,在第二十六章中发现更多关于War插件和Jetty插件的说明。你可以在gradle中samples/webApplication找到更多的java项目示例。

原文地址:http://www.gradle.org/docs/cur ... .html
翻译者:wellchang
邮箱:2483808264@qq.com

如对翻译内容有异议,请在评论区提出或联系作者

【转载】Gradle学习 第十章:网络应用快速入门的更多相关文章

  1. 【转】MyBatis学习总结(一)——MyBatis快速入门

    [转]MyBatis学习总结(一)——MyBatis快速入门 一.Mybatis介绍 MyBatis是一个支持普通SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis消除了几乎所有的JDBC ...

  2. MyBatis学习总结(一)——MyBatis快速入门(转载)

    本文转载自http://www.cnblogs.com/jpf-java/p/6013537.html MyBatis是一个支持普通SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis消除了 ...

  3. 大数据技术之_09_Flume学习_Flume概述+Flume快速入门+Flume企业开发案例+Flume监控之Ganglia+Flume高级之自定义MySQLSource+Flume企业真实面试题(重点)

    第1章 Flume概述1.1 Flume定义1.2 Flume组成架构1.2.1 Agent1.2.2 Source1.2.3 Channel1.2.4 Sink1.2.5 Event1.3 Flum ...

  4. JavaScript学习02(js快速入门)

    快速入门 基本语法 JavaScript的语法和Java的语法类似,每个语句以;结束,语句块用{...}.但是JavaScrip并不强制要求在每个语句的结尾加;,浏览器中负责执行JavaScript代 ...

  5. MyBatis学习总结(一)——MyBatis快速入门

    一.Mybatis介绍 MyBatis是一个支持普通SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis消除了几乎所有的JDBC代码和参数的手工设置以及对结果集的检索封装.MyBatis可以 ...

  6. 【Python】【学习笔记】1.快速入门

    1.软件安装 从官网下载相应版本的安装包,一般不大. https://www.python.org/ 安装一路默认即可 2. 参考教程:快速入门:十分钟学会Python 本文的内容介于教程(Totur ...

  7. MyBatis学习总结(一)——MyBatis快速入门

    一.Mybatis介绍 MyBatis是一个支持普通SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis消除了几乎所有的JDBC代码和参数的手工设置以及对结果集的检索封装.MyBatis可以 ...

  8. Mybatis学习(一) - 快速入门

    MyBatis是支持普通SQL查询,存储过程和高级映射的优秀持久层框架. MyBatis消除了几乎所有的JDBC代码和参数的手工设置以及对结果集的检索封装. MyBatis可以使用简单的XML或注解用 ...

  9. MyBatis学习笔记(一)——MyBatis快速入门

    转自孤傲苍狼的博客:http://www.cnblogs.com/xdp-gacl/p/4261895.html 一.Mybatis介绍 MyBatis是一个支持普通SQL查询,存储过程和高级映射的优 ...

随机推荐

  1. thread_asyncio

    thread_asyncio # 使用多线程:在携程中集成阻塞io import asyncio from concurrent.futures import ThreadPoolExecutor i ...

  2. Django项目中出现的错误及解决办法(ValueError: Dependency on app with no migrations: customuser)

    写项目的时候遇到了类似的问题,其实就是没有生成迁移文件,执行一下数据库迁移命令就好了 ValueError: Dependency on app with no migrations: customu ...

  3. LeetCode 241. Different Ways to Add Parentheses为运算表达式设计优先级 (C++)

    题目: Given a string of numbers and operators, return all possible results from computing all the diff ...

  4. 【day04】PHP

    一. 运算符 1.按功能分  (1)算术运算符  (2)字符运算符  (3)赋值运算符  (4)比较运算符  (5)逻辑运算符  (6)错误抑制符  (7)执行运算符 2.逻辑运算符 : ! & ...

  5. nowcoder907B n的约数

    题意 t次询问,每次给你一个数n,求在[1,n]内约数个数最多的数的约数个数 \(t \le 500,n \le 10^{19}\) 思路 首先可以想到将n质因数分解.即\(n= \prod\limi ...

  6. Linux性能优化实战学习笔记:第四十七讲

    一.上节回顾 上一节,我们梳理了,应用程序容器化后性能下降的分析方法.一起先简单回顾下.容器利用 Linux 内核提供的命名空间技术,将不同应用程序的运行隔离起来,并用统一的镜像,来管理应用程序的依赖 ...

  7. [LeetCode] 222. Count Complete Tree Nodes 求完全二叉树的节点个数

    Given a complete binary tree, count the number of nodes. Note: Definition of a complete binary tree ...

  8. .NET Core:跨域

    在Startup中的ConfigureServices方法中配置:services.AddCors(options => options.AddPolicy("any", b ...

  9. (一)golang--初识go语言

    学习来源:https://www.bilibili.com/video/av35928275/?p=1  尚硅谷的(我学spring.springmvc和mybatis就是他们的课) 使用1.9.2的 ...

  10. 《Linux就该这么学》培训笔记_ch02_一些必须掌握的Linux命令

    本文在原来作者的基础上做一些符合自己的修改.原文参考: <Linux就该这么学>培训笔记_ch02_一些必须掌握的Linux命令.     本章的内容虽然多,基本都是书本原话,但是笔记能精 ...