我在servdle中添加了servlet api作为依赖项,但是当我想在我的Java类中导入它时,它不起作用。与Mockito框架相同。
我的gradle.build文件看起来像这样:
group 'Dontknownow'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.1.4-3'
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'java'
apply plugin: 'kotlin2js'
apply plugin: 'war'
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'org.mockito:mockito-core:2.+'
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
}
答案 0 :(得分:0)
我认为" +"在我的build.gradle是问题
而不是使用
testCompile 'org.mockito:mockito-core:2.+'
我输入了绝对版本:
testCompile 'org.mockito:mockito-core:2.7.19'
还有https://guides.gradle.org/building-java-web-applications/
上Mockito的替代进口声明import org.mockito.Mock;
import org.mockito.MockitoAnnotations;