2017-11-19 12 views
0



서블릿 api를 Gradle에 종속성으로 추가했지만 자바 클래스에서 가져 오기를 수행 할 때 작동하지 않습니다. 모키토 프레임 워크와 같은 것.추가 된 Gradle 종속성을 Java 클래스로 가져올 수 없습니다.

내 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' 
} 

이 오류 내 인 IntelliJ처럼 모습입니다가 :

the name mockito is marked red in the import-statement

+0

그것은 어리석은 사본이 아닙니다. 이것이 IntelliJ에서 build.gradle 파일을 생성하는 방법입니다. –

답변

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/

import org.mockito.Mock; 
import org.mockito.MockitoAnnotations;