目标:https://github.com/davenkin/springmvc4-helloworld

使用SpringMVC编写的一个HelloWorld程序。

初学Gradle只能一步步摸索前进。

该项目对应的build.gradle

apply plugin: 'idea'
apply plugin: 'jetty' repositories {
mavenCentral()
} dependencies {
compile 'org.springframework:spring-webmvc:4.0.6.RELEASE'
providedCompile 'javax.servlet:servlet-api:2.5'
} task wrapper(type: Wrapper) {
gradleVersion = '3.0'
}

文件结构:

D:\N3verL4nd\Desktop\springmvc4-helloworld>tree /f
卷 本地磁盘 的文件夹 PATH 列表
卷序列号为 00000200 0006:08B0
D:.
│ .gitignore
│ build.gradle
│ gradlew
│ gradlew.bat
│ README.md

├─gradle
│ └─wrapper
│ gradle-wrapper.jar
│ gradle-wrapper.properties

└─src
└─main
├─java
│ └─hello
│ HomeController.java

├─resources
│ applicationContext.xml

└─webapp
└─WEB-INF
│ spring-servlet.xml
│ web.xml

└─jsp
hello.jsp D:\N3verL4nd\Desktop\springmvc4-helloworld>

编译该项目:

D:\N3verL4nd\Desktop>git clone https://github.com/davenkin/springmvc4-helloworld
Cloning into 'springmvc4-helloworld'...
remote: Counting objects: 127, done.
Receiving objects: 37% (47/127) 0 (delta 0), pack-reused 127 ts: 30% (39/127)
Receiving objects: 100% (127/127), 68.75 KiB | 0 bytes/s, done.
Resolving deltas: 100% (34/34), done. D:\N3verL4nd\Desktop>cd springmvc4-helloworld D:\N3verL4nd\Desktop\springmvc4-helloworld>gradle build
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details
The Jetty plugin has been deprecated and is scheduled to be removed in Gradle 4.0. Consider using the Gretty (https://github.com/akhikhl/gretty) plugin instead.
at build_6z4w2swcyg02xyim9zhjsclh0.run(D:\N3verL4nd\Desktop\springmvc4-helloworld\build.gradle:2)
:compileJava
:processResources
:classes
:war
:assemble
:compileTestJava NO-SOURCE
:processTestResources NO-SOURCE
:testClasses UP-TO-DATE
:test NO-SOURCE
:check UP-TO-DATE
:build BUILD SUCCESSFUL Total time: 26.685 secs
D:\N3verL4nd\Desktop\springmvc4-helloworld>gradle tasks
The Jetty plugin has been deprecated and is scheduled to be removed in Gradle 4.0. Consider using the Gretty (https://github.com/akhikhl/gretty) plugin instead.
at build_6z4w2swcyg02xyim9zhjsclh0.run(D:\N3verL4nd\Desktop\springmvc4-helloworld\build.gradle:2)
:tasks ------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------ Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles main classes.
clean - Deletes the build directory.
jar - Assembles a jar archive containing the main classes.
testClasses - Assembles test classes.
war - Generates a war archive with all the compiled classes, the web-app content and the libraries. Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating] Documentation tasks
-------------------
javadoc - Generates Javadoc API documentation for the main source code. Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'springmvc4-helloworld'.
components - Displays the components produced by root project 'springmvc4-helloworld'. [incubating]
dependencies - Displays all dependencies declared in root project 'springmvc4-helloworld'.
dependencyInsight - Displays the insight into a specific dependency in root project 'springmvc4-helloworld'.
dependentComponents - Displays the dependent components of components in root project 'springmvc4-helloworld'. [incubating]
help - Displays a help message.
model - Displays the configuration model of root project 'springmvc4-helloworld'. [incubating]
projects - Displays the sub-projects of root project 'springmvc4-helloworld'.
properties - Displays the properties of root project 'springmvc4-helloworld'.
tasks - Displays the tasks runnable from root project 'springmvc4-helloworld'. IDE tasks
---------
cleanIdea - Cleans IDEA project files (IML, IPR)
idea - Generates IDEA project files (IML, IPR, IWS) Verification tasks
------------------
check - Runs all checks.
test - Runs the unit tests. Web application tasks
---------------------
jettyRun - Uses your files as and where they are and deploys them to Jetty.
jettyRunWar - Assembles the webapp into a war and deploys it to Jetty.
jettyStop - Stops Jetty. Rules
-----
Pattern: clean<TaskName>: Cleans the output files of a task.
Pattern: build<ConfigurationName>: Assembles the artifacts of a configuration.
Pattern: upload<ConfigurationName>: Assembles and uploads the artifacts belonging to a configuration. To see all tasks and more detail, run gradle tasks --all To see more detail about a task, run gradle help --task <task> BUILD SUCCESSFUL Total time: 1.348 secs
D:\N3verL4nd\Desktop\springmvc4-helloworld>

测试:

如上所示,本地有Gradle环境,如果没有的话需要使用gradlew build命令

它会自动去下载gradle运行环境

由于未知的下载速度问题,最好使用梯子,下载下来如下配置也是可以的。

D:\N3verL4nd\Desktop\springmvc4-helloworld\gradle\wrapper\gradle-wrapper.properties

#Wed Sep 28 09:06:11 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip
distributionUrl=gradle-3.0-bin.zip

参考:

https://www.zybuluo.com/xtccc/note/275168#wrapper-gradlew

http://dengyin2000.iteye.com/blog/2191658

http://blog.csdn.net/u011054333/article/details/53999590

如何运行使用gradle打包的项目的更多相关文章

  1. gradle 打包springboot项目,找不到项目jar application.class

    如题:gradle 打包springboot项目,找不到项目jar入口main方法:application.class 检查:lib/目录下没有相应项目的jar包 用gradle命令行查看日志:gra ...

  2. weexpack打包weex项目运行/打包记录

    构建weex项目 安装weex-toolkit cnpm install -g weex-toolkit 初始化一个项目只需新建文件夹并在目录下执行 weex init 即可 安装依赖:cnpm in ...

  3. IntelliJ IDEA打包WAR并部署运行(mac osx)将Web项目War包部署到Tomcat服务器基本步骤(完整版)

    用IntelliJ IDEA做web开发体验很好,但导出war包比eclipse麻烦了不少,以下是解决方案: 打包:1.自动打包:File —> Project Structure —> ...

  4. webpack打包vue项目之后生成的dist文件该怎么启动运行

    亲测,webpack打包vue项目之后生成的dist文件可以部署到 express 服务器上运行. 我的vue项目结构如下: 1. 进入该vue项目目录,打开git bash,执行:npm run b ...

  5. 用leiningen来运行和打包clojure项目

    今天是2017年5月24日.隔壁team用clojure写了个工具,我们要拿来用,于是弄了个leiningen来尝试.还没有最后成功,先记录一下一些连蒙带猜的步骤,以免忘记. 一.单独运行的cloju ...

  6. 用gradle把springboot项目打包成jar

    ``` 用gradle把springboot项目打包成jar ```### build.gradle 中添加 buildscript { repositories { mavenLocal() mav ...

  7. docker 运行jenkins及vue项目与springboot项目(三.jenkins的使用及自动打包vue项目)

    docker 运行jenkins及vue项目与springboot项目: 一.安装docker 二.docker运行jenkins为自动打包运行做准备 三.jenkins的使用及自动打包vue项目 四 ...

  8. 在eclipse中用gradle搭建MapReduce项目

    我用的系统是ubuntu14.04新建一个Java Project. 这里用的是gradle打包,gradle默认找src/main/java下的类编译.src目录已经有了,手动在src下创建main ...

  9. Android Ant 和 Gradle 打包流程和效率对照

    一.Ant 打包:(下载ant.配置环境变量就不说了) 1.进入命令行模式,并切换到项目文件夹.运行例如以下命令为ADT创建的项目加入ant build支持: android update proje ...

随机推荐

  1. $HDOJ5542\ The\ Battle\ of\ Chibi$ 数据结构优化$DP$

    $AcWing$ $Description$ $Sol$ 首先显然是是以严格递增子序列的长度为阶段,由于要单调递增,所以还要记录最后一位的数值 $F[i][j]$表示前$i$个数中以$A_i$结尾的长 ...

  2. java之set接口

    1.set集合不能存储重复的元素, 2.HashSet集合不能保证的迭代顺序与元素存储顺序相同. 3.HashSet集合,采用哈希表结构存储数据,保证元素唯一性的方式依赖于:hashCode()与eq ...

  3. 《Java开发学习大纲文档》V8.0

    <Java开发学习大纲文档>V8.0 第八版是以实战作为核心,同时也包含前面所有版本的精华部分,第八版加入的部分有云开发(阿里云OSS存储.(github)gitlab+docker网站自 ...

  4. 「CodeForces 546B」Soldier and Badges 解题报告

    CF546B Soldier and Badges 题意翻译 给 n 个数,每次操作可以将一个数 +1,要使这 n 个数都不相同, 求最少要加多少? \(1 \le n \le 3000\) 感谢@凉 ...

  5. (四)注册登录--重用Django

    一.使用已有登录功能 (1)进入Lib\sitepackages\django\contrib\admin\templates\registration下,将对应模板,复制到项目template模板中 ...

  6. matplotlib绘制符合论文要求的图片

    最近需要将实验数据画图出来,由于使用python进行实验,自然使用到了matplotlib来作图. 下面的代码可以作为画图的模板代码,代码中有详细注释,可根据需要进行更改. # -*- coding: ...

  7. 删除centos自带的openjdk

    [wj@master hadoop]$ rpm -qa | grep javajava-1.7.0-openjdk-1.7.0.191-2.6.15.5.el7.x86_64python-javapa ...

  8. python小功能记录

    本博客会不断完善,记录python小功能. 1. 合并两个字典 # in Python 3.5+ >>> x = {'a': 1, 'b': 2} >>> y = ...

  9. java架构之路(多线程)JUC并发编程之Semaphore信号量、CountDownLatch、CyclicBarrier栅栏、Executors线程池

    上期回顾: 上次博客我们主要说了我们juc并发包下面的ReetrantLock的一些简单使用和底层的原理,是如何实现公平锁.非公平锁的.内部的双向链表到底是什么意思,prev和next到底是什么,为什 ...

  10. 1、AutoMapper简单介绍

    官网:http://automapper.org/ 源码:https://github.com/AutoMapper/AutoMapper NUGET安装: PM> Install-Packag ...