intellij-idea - Idea项目中的Gradle依赖项

标签 intellij-idea gradle build.gradle embedded-jetty

我正在尝试使用Gradle,但是Idea看不到依赖项。这是我的build.gradle

    group 'me.ozka'
    version '1.0.1'

    buildscript {
       ext.kotlin_version = '1.0.3'

    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

       }
    }

   apply plugin: 'java'
   apply plugin: 'kotlin'


   sourceCompatibility = 1.5

repositories {
    mavenCentral()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    testCompile group: 'junit', name: 'junit', version: '4.11'
    compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.20'
    compile 'org.eclipse.jetty:jetty-server:9.0.0.RC2'
    compile 'org.eclipse.jetty:jetty-servlet:9.0.0.RC2'

}

当我尝试导入import org.eclipse.jetty.server.Server;想法告诉我一个错误。我做错了什么?

upd:我也没有在Idea External库文件夹中看到jar文件。

upd2:我要添加到生成文件中,应用插件:“jetty”,它可以解决我的问题!

最佳答案

您需要刷新gradle依赖项。

这是一些方法。

方法1(GUI):

  • 转到View -> Tool Windows -> Gradle
  • 单击大刷新按钮(刷新所有gradle项目)。

  • 方法2(命令):
    gradle build --refresh-dependencies

    关于intellij-idea - Idea项目中的Gradle依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38954720/

    相关文章:

    module - 如何在 IntelliJ 中设置具有相同层次模块的多模块项目?

    java - Intellij IDEA 代码覆盖率不起作用

    java - JOptionPane.showInputDialog 使我的程序崩溃

    安卓工作室 : Project refresh failed. 。打开 zip 文件时出错

    android - Gradle 找不到 'testDebug' 任务

    java - 删除 JComboBox 中的向下箭头

    android - 无法使用 Gradle 将 ViewPagerIndicator 添加到应用程序

    gradle - 通过gradle运行JUNIT时出错

    android - 错误 :Minifying the variant used for tests is not supported when using Jack

    web-applications - 如何在 gradle 中设置 webAppDirName