Java - compilation error: cannot access Function

Java - compilation error: cannot access Function

我有 osgi 项目。每个包都是一个单独的 Maven 项目。项目足够大,包括大约 10 个包。一切正常。

今天我又添加了一个库 - https://code.google.com/p/owasp-java-html-sanitizer/。我已经设置了所有依赖项,ide (netbeans 8) 显示一切正常。但是我在这个方法中得到了以下编译代码:

@Override
public void sanitize(Map<String,Object> policies){
    PolicyFactory  policy=(PolicyFactory) policies.get("html0");
    this.code=policy.sanitize(this.code);
}

在方法的第二行 (this.code...) 我得到以下编译错误:无法访问函数。看不懂是什么意思。。。
编辑
导入部分:

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.owasp.html.PolicyFactory;


编辑

COMPILATION ERROR : 
-------------------------------------------------------------
com/subjects/SubjectDirItemCore.java:[166,24] error: cannot access Function
1 error
-------------------------------------------------------------
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.687s
Finished at: Wed Feb 18 16:11:11 MSK 2015
Final Memory: 14M/205M


编辑
- 我尝试通过 mvn install -X

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project com.....: Compilation failure ..../subjects/SubjectDirItemCore.java:[166,24] error: cannot access Function

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure /..../subjects/SubjectDirItemCore.java:[166,24] error: cannot access Function

at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:656) at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more [ERROR]

这似乎是 jar 版本问题。最有可能的是,包含 class PolicyFactory 的较新版本的 jar 降低了方法清理的可见性级别。必须有你应该使用的新方法,因为早期的方法受到限制。

我找到了 anwser - 我使用 guava 12 而不是 guava 11。我选择了 12,因为它是作为 osgi 包的第一个版本。

在我的例子中,当工件在没有适当的 pom.xml 的情况下发布到本地 Maven 存储库时,就会发生这种情况,因此无法下载传递依赖项。查找未找到的 class 所在的工件,然后将其手动输入到 pom.xml 中,这应该可以解决问题。