Gradle中使用Tomcat插件

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.bmuschko:gradle-tomcat-plugin:2.1'
    }
}

subprojects {
    apply plugin : "java"
    repositories {
        mavenCentral()
    }
}


group 'com.zhen'
version '1.0-SNAPSHOT'

apply plugin: "war"
apply plugin: 'com.bmuschko.tomcat'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
    compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.17'
    providedCompile 'javax.servlet:javax.servlet-api:3.1.0'

    def tomcatVersion = '7.0.59'
    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}"
}

只需要在build.gradle添加红色部分配置即可,然后运行命令:
gradle build
gradle tomcatRunWar
展开阅读全文

没有更多推荐了,返回首页