Gradle mounted reliance gradle providedCompile, compile and runtime difference
A, Gradle add-dependent error
build.gradle file to add dependencies:
providedCompile group: 'org.projectlombok', name: 'lombok', version: '1.18.8'
Gradle will encounter an error when adding a dependency of build.gradle file, the error message is as follows:
Could not find method providedCompile() for arguments [{group=org.projectlombok, name=lombok, version=1.18.8}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler
Two, Gradle reason given
Add on top of a dependent after being given a prompt but, after inquiries found that the plug is needed not added.
This reliance on and add the prefix providedCompile, compile and runtime have relationship.
build.gradle add plug-ins
allprojects {
group = 'com.test'
version = '1.0-SNAPSHOT'
buildDir = 'target'
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'idea'
apply plugin: 'maven'
}
Complie: Your jar package or rely on the code, need to rely on at compile time, when running also requires, then use compile
Dependency Complie prefix needs to be configured in the file build.gradle
apply plugin: 'war'
orapply plugin: 'java'然后在添加依赖就不会报错了
providedCompile: your bag or jar dependent code at compile time only need to rely on, is not required at run time, then use providedCompile
Use providedCompile prefix dependent, you need to configure the file build.gradle
apply plugin: 'war'
然后在添加依赖就不会报错了
runtime: your bag or jar dependent code at runtime only need to rely on, does not need at compile time, then use the runtime
Use prefix runtime dependencies, you need to configure the file build.gradle
apply plugin: 'java'
然后在添加依赖就不会报错了