有人知道为什么会出现这个错误吗?
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(Z)V
at com.google.common.collect.Lists.computeArrayListCapacity(Lists.java:105)
at com.google.common.collect.Lists.newArrayList(Lists.java:98)
at com.google.javascript.jscomp.ComposeWarningsGuard.<init> (ComposeWarningsGuard.java:83)
at com.google.javascript.jscomp.CompilerOptions.<init>(CompilerOptions.java:791)
代码
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import com.google.javascript.jscomp.CompilationLevel;
import com.google.javascript.jscomp.CompilerOptions;
import com.google.javascript.jscomp.Compiler;
import com.google.javascript.jscomp.SourceFile;
public class MyJavaScriptCompressor {
private Compiler cloJsCompressor;
public MyJavaScriptCompressor() {
}
public String closureCompress(File source) {
CompilerOptions opt = new CompilerOptions();
int mode = 1;
CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel( opt );
Compiler.setLoggingLevel(Level.OFF);
cloJsCompressor = new Compiler();
cloJsCompressor.disableThreads();
List<SourceFile> externs = Collections.emptyList();
List<SourceFile> inputs = Arrays.asList(SourceFile.fromFile(source));
cloJsCompressor.compile( externs, inputs, opt );
return cloJsCompressor.toSource();
}
}
构建路径包括
compiler.jar
jsoup.jar
yuicompressor.jar
我怎么能摆脱它?!
编辑:
此行中出现错误:
CompilerOptions opt = new CompilerOptions();
答案 0 :(得分:1)
解决..
eclipse项目根目录中的.classpath缺少该行:<classpathentry kind="lib" path="lib/compiler.jar"/>
我不知道 - 为什么日食无法自动解决..