🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 1.groovy(绝妙的) 看来这个语言的创建者对自己的创造很是满意啊。取名绝妙!来构建groovy项目试试 ~~~ apply plugin:'groovy' apply plugin:'eclipse' repositories{ mavenCentral() } dependencies{ compile 'org.codehaus.groovy:groovy-all:2.3.6' testCompile 'junit:junit:4.11' } ~~~ 构建一下项目 ~~~ qianhuis-Mac-mini:0108 qianhui$ gradle build :compileJava UP-TO-DATE :compileGroovy UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :jar UP-TO-DATE :assemble UP-TO-DATE :compileTestJava UP-TO-DATE :compileTestGroovy UP-TO-DATE :processTestResources UP-TO-DATE :testClasses UP-TO-DATE :test UP-TO-DATE :check UP-TO-DATE :build UP-TO-DATE BUILD SUCCESSFUL Total time: 3.66 secs ~~~ ## 2.web项目 build.gradle ~~~ apply plugin:'war' ~~~ 构建一下 ~~~ qianhuis-Mac-mini:0108_1 qianhui$ gradle build :compileJava UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :war UP-TO-DATE :assemble UP-TO-DATE :compileTestJava UP-TO-DATE :processTestResources UP-TO-DATE :testClasses UP-TO-DATE :test UP-TO-DATE :check UP-TO-DATE :build UP-TO-DATE BUILD SUCCESSFUL Total time: 2.935 secs ~~~ 然后在项目目录build/libs中生存了war压缩包。会将src/main/webapp里的文件编译进压缩包呢。 ## 3.运行web项目 build.gradle中加入下面标示: ~~~ apply plugin:'jetty' ~~~ 运行gradle jettyRunWar命令 ~~~ qianhuis-Mac-mini:0108_1 qianhui$ gradle jettyRunWar :compileJava UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :war UP-TO-DATE > Building 80% > :jettyRunWar > Running at http://localhost:8080/0108_1 ~~~ 这个时候我们在网页中输入上面的http://localhost:8080/0108_1会访问该网页。然后按Ctrl+c退出。