plugins { id 'java' id "io.franzbecker.gradle-lombok" version "3.1.0" //在此添加插件否则lombok引用会失败 } group 'com.demo' version '1.0-SNAPSHOT' sourceCompatibility = 1.8 repositories { //mavenCentral() maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } } dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' compile group: 'io.netty', name: 'netty-all', version: '4.1.32.Final' compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.47' compile group: 'org.mybatis', name: 'mybatis', version: '3.4.6' compile group: 'log4j', name: 'log4j', version: '1.2.17' compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25' providedCompile group: 'org.projectlombok', name: 'lombok', version: '1.16.18' classpath "io.franzbecker:gradle-lombok:3.1.0" } apply plugin: "io.franzbecker.gradle-lombok" //再次应用插件 只需这两行即可实现lombok的功能 tasks.withType(JavaCompile) { options.encoding = "UTF-8" }