gpt4 book ai didi

Java - 编译错误 : cannot access Function

转载 作者:行者123 更新时间:2023-11-30 11:08:22 25 4
gpt4 key购买 nike

我有 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]

最佳答案

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

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com