2017-08-09 51 views
0

我正嘗試使用spring mvc框架構建Web服務。我正在使用IntelliJ Community Edition IDE和gradle構建系統。無法使用Gradle添加IntelliJ Community Edition中的應用程序服務器

的build.gradle

buildscript { 
    ext { 
     kotlinVersion = '1.1.3-2' 
     springBootVersion = '1.5.6.RELEASE' 
    } 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
     classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") 
     classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}") 
    } 
} 

apply plugin: 'kotlin' 
apply plugin: 'kotlin-spring' 
apply plugin: 'eclipse' 
apply plugin: 'org.springframework.boot' 

version = '0.0.1-SNAPSHOT' 
sourceCompatibility = 1.8 
compileKotlin { 
    kotlinOptions.jvmTarget = "1.8" 
} 
compileTestKotlin { 
    kotlinOptions.jvmTarget = "1.8" 
} 

repositories { 
    mavenCentral() 
} 


dependencies { 
    compile('org.springframework.boot:spring-boot-starter-jersey') 
    compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:${kotlinVersion}") 
    compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}") 
    testCompile('org.springframework.boot:spring-boot-starter-test') 
    testCompile 'org.springframework.boot:spring-boot-starter-tomcat' 

} 

應用構建成功。但是我找不到使用Gradle在Community Edition中添加應用程序服務器(Tomcat)的選項。

Welcome to Gradle 3.5.1. 

To run a build, run gradle <task> ... 

To see a list of available tasks, run gradle tasks 

To see a list of command-line options, run gradle --help 

To see more detail about a task, run gradle help --task <task> 

BUILD SUCCESSFUL 

Total time: 4.817 secs 

Process finished with exit code 0 

有誰知道如何在Gradle系統的IntelliJ Community Edition中添加tomcat應用服務器?

enter image description here

+0

據我所知,此功能僅在終極版中可用。 –

+0

@ C-Otto是的,終極版有內置選項,但應該有解決方法來添加它並完成此操作。 –

+0

當然,只需支付功能:) –

回答

1

你可以使用這個插件https://github.com/bmuschko/gradle-tomcat-pluginGradle在Community Edition放入Tomcat。

添加這個插件在buildscript依賴

buildscript { 
    repositories { 
     mavenCentral() 
     jcenter() 
    } 
    dependencies { 
     ..... 
     classpath 'com.bmuschko:gradle-tomcat-plugin:2.3' 
    } 
} 

應用此插件apply plugin: 'com.bmuschko.tomcat'

現在你需要Tomcat的運行時庫添加到tomcat的配置。我有這可能適合你。

repositories { 
    mavenCentral() 
} 

dependencies { 
    .... 
    def tomcatVersion = '8.0.42' 
    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}" 
} 

希望這對你有幫助。

相關問題