我正在尝试使用spring mvc框架构建Web服务。我正在使用IntelliJ Community Edition IDE和gradle构建系统。
的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应用程序服务器?
答案 0 :(得分:2)
据我所知,它不适用于Community Edition。 它仅适用于Ultimate Edition。
请参阅此链接:
https://www.jetbrains.com/idea/features/editions_comparison_matrix.html
答案 1 :(得分:1)
您可以使用此插件https://github.com/bmuschko/gradle-tomcat-plugin在社区版中添加Gradle
的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}"
}
希望这对你有所帮助。