【问题标题】:Unable to add application server in IntelliJ Community Edition with Gradle无法使用 Gradle 在 IntelliJ 社区版中添加应用程序服务器
【发布时间】:2018-01-16 22:21:38
【问题描述】:

我正在尝试使用 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

有谁知道如何在 IntelliJ Community Edition 中使用 Gradle 系统添加 tomcat 应用服务器?

【问题讨论】:

  • 据我所知,此功能仅在终极版中可用。
  • @C-Otto 是的,终极版中有内置选项,但应该有办法添加它并完成这项工作。
  • 当然,只需为该功能付费 :)
  • maven dzone.com/articles/headless-setup-java-project 有解决方法,但找不到 gradle

标签: java spring tomcat intellij-idea gradle


【解决方案1】:

据我所知,它在社区版中不可用。 它仅在终极版中可用。

请参考此链接:

https://www.jetbrains.com/idea/features/editions_comparison_matrix.html

【讨论】:

  • 不。你可以这样做,希望我的回答可以帮助你!
【解决方案2】:

您可以使用此插件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}"
}

希望对你有所帮助。

【讨论】:

    猜你喜欢
    • 2022-11-11
    • 2021-09-07
    • 2020-02-13
    • 2021-03-01
    • 2020-12-20
    • 2017-10-21
    • 2021-03-13
    • 1970-01-01
    • 2022-11-21
    相关资源
    最近更新 更多