您的sourceSet对我来说不正确.我会尝试:
sourceSets { main { java { srcDirs = ['src/main/java'] } } test { java { srcDirs = ['src/test/java'] } } }