Java - 编译错误 : cannot access Function

标签 java maven osgi owasp

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

今天我又添加了一个库 - 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]

最佳答案

在我的例子中,当 Artifact 被发布到本地 Maven 存储库而没有正确的 pom.xml 时,就会发生这种情况,因此传递依赖项没有被下载。查找未找到的类所在的 Artifact 并手动将其输入到 pom.xml 中,这应该可以解决问题。

关于Java - 编译错误 : cannot access Function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28584798/

相关文章:

java - 合作流消费者的设计思路?

java - 如何在循环末尾连接数组

java - Apache Karaf 中的基本身份验证

java - 使用 DS 多次实例化 Bundle

java - 如何修复java.lang.UnsupportedClassVersionError:不支持的major.minor版本

java - 使用 Java 和 Apache 客户端的摘要身份验证 : Always 401 Unauthorized

java - 使用 maven-eclipse-plugin 将文件夹中的依赖项 jar 文件指定到 eclipse 项目中,而不是 M2_REPO 变量

java - 从命令行跳过 sql-maven-plugin 执行

java - 如何将普通 Java 项目功能添加到 Eclipse (.ear) 中的 EJB 项目?

java - 读我自己的Jar list