IDEA为Gradle添加tomcat插件

2017-09-01  本文已影响0人  外匹夫

https://github.com/bmuschko/gradle-tomcat-plugin
http://www.jianshu.com/p/3a81f0dd4418
http://www.cnblogs.com/newflydd/p/4980524.html

:我用了第一个链接的tomcat8.5报错,最后换成8.0
废话不多说,直接上传build.gradle代码(里面用的tomcat插件我用/* */注释起来)

// Tomcat 需要
/*buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "com.bmuschko:gradle-tomcat-plugin:2.2.3"
    }
}*/

apply plugin:"war"
apply plugin: 'idea'
/*apply plugin: "com.bmuschko.tomcat"*/

dependencies{
    // set project dependencies
    compile project(":ROMSBusiness")
    compile project(":ROMSCache")
    compile project(":ROMSUtils")

    compile(
            "org.springframework:spring-webmvc:$springVersion"
    )

    //set provided compile
    providedCompile(
            "javax.servlet:javax.servlet-api:3.1.0",
            "javax.servlet.jsp:jsp-api:2.2.1-b03",
            "javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:1.2.1"
    )
// 配置 Tomcat 插件
   /* def tomcatVersion = '8.0.27'
    tomcat   "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
            "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}",
            "org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}"*/
}

webAppDirName = 'WebContent'

task('jarPath')<<{
    configurations.runtime.resolve().each {
        print it.toString()+";"
    }
    println();
}
//tomcat 插件的配置
/*tomcat {
    httpPort = 8090
    stopPort = 8091
    //httpsPort = 8091
    enableSSL = true
}

tomcatRun{
    contextPath= 'RomsAdmin'
    URIEncoding= 'UTF-8'
    reloadable = 'true'
}*/

保存完之后,gradle refresh 会出现 web application,然后运行tomcatRun

图片.png

最后运行的结果:

图片.png

最后再访问Url测试吧。

上一篇下一篇

猜你喜欢

热点阅读