Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin:未解析的引用:javaClass_Java_Kotlin - Fatal编程技术网

Kotlin:未解析的引用:javaClass

Kotlin:未解析的引用:javaClass,java,kotlin,Java,Kotlin,我希望有人在构建我的java/Kotlin项目时遇到了我所看到的问题。 该项目与java和kotlin互操作,版本如下: JDK1.7 科特林0.9.66 Gradle(包装器)2.0 在我做了一些更改之前,Kotlin编译得很好,即将一些java类转换为等效的Kotlin版本 以下是我看到的错误: c:\projects\myproject>gradlew :java:workspace:models:compileKotlin --stacktrace :java:

我希望有人在构建我的java/Kotlin项目时遇到了我所看到的问题。 该项目与java和kotlin互操作,版本如下:

  • JDK1.7
  • 科特林0.9.66
  • Gradle(包装器)2.0
在我做了一些更改之前,Kotlin编译得很好,即将一些java类转换为等效的Kotlin版本

以下是我看到的错误:

  c:\projects\myproject>gradlew  :java:workspace:models:compileKotlin  --stacktrace     :java:workspace:models:compileKotlin

w: Annotations path entry points to a non-existent location:
C:\projects\myproject\java\workspace\models\annotations

e: C:\projects\CustomerProfileEmail.kt: (15, 32): Unresolved reference: toLowerCase
e: C:\projects\CustomerProfilePhone.kt: (34, 22): Unresolved reference: equalsIgnoreCase
e: C:\projects\Account.kt: (17, 21): Unresolved reference: javaClass
e: C:\projects\Account.kt: (18, 21): Unresolved reference: javaClass
e: C:\projects\Account.kt: (31, 15): Unresolved reference: indexOf
e: C:\projects\Account.kt: (35, 15): Expression 'length' of type 'kotlin.Int' cannot be invoked as a function. The function invoke() is not found
e: C:\projects\Account.kt: (39, 15): Expression 'length' of type 'kotlin.Int' cannot be invoked as a function. The function invoke() is not found
e: C:\projects\Balance.kt: (10, 21): Unresolved reference: javaClass
e: C:\projects\Balances.kt: (12, 21): Unresolved reference: firstOrNull
e: C:\projects\Balances.kt: (12, 35): Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) -> ...} notation
e: C:\projects\Debit.kt: (7, 12):Unresolved reference: javaClass
e: C:\projects\ProgramR.kt: (12, 21): Unresolved reference: javaClass
e: C:\projects\ProgramR.kt: (13, 21): Unresolved reference: javaClass
e: C:\projects\Transaction.kt: (7, 12): Unresolved reference: javaClass
e: C:\projects\Transaction.kt: (7, 40): Unresolved reference: javaClass
e: C:\projects\Adjustment.kt: (13,21): Unresolved reference: javaClass
e: C:\projects\Reward.kt: (12, 24): Unresolved reference: javaClass
:java:workspace:models:compileKotlin FAILED

FAILURE: Build failed with an exception.
以下是源代码的示例:

import javax.xml.bind.annotation.*

XmlAccessorType(XmlAccessType.FIELD)
XmlType
XmlSeeAlso(javaClass<LoyaltyCredit>(), javaClass<Debit>())
public open class Transaction: TransactionParent(){
    public var account: Account? = null
    public var balances: Balances? = null
    public var rewards: Rewards? = null
}
我已经看到了这一点:没有帮助


任何帮助都将不胜感激

将您的脚本与Kotlin关于Gradle的内容进行比较

Kotlin Stdlib依赖项应该在另一个作用域中,而不是
buildscript

另外,应使用
apply plugin

应用Kotlin插件,谢谢您的提示。我正在处理一个非常复杂的脚本。因此,尽管我有与引用的脚本相同的脚本,但它在导入的脚本行中被覆盖。参考资料有助于寻找正确的方向@WolfBane请更新您的问题或在此处添加对您找到的实际解决方案的评论。如果您发现了您所做的修复,但在接受的答案中未直接提及,请使用描述您如何解决该问题的编辑更新您的问题。否则,您可能会发现这个问题,并且不知道“参考有助于寻找正确方向”在确定解决方案时的实际含义。
repositories {
    mavenCentral()
}

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.connorgarvey.gradle:gradle-grails-wrapper:1.0'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:0.9.66'
        classpath 'org.jetbrains.kotlin:kotlin-stdlib:0.9.66'
    }
}

apply from: 'build/includes.gradle'