编译器找不到我作为Maven依赖项的类

佐佐木健(Rodrigo Sasaki)

我有一个依赖于 RESTEasy JAX RS Client

我将其添加为我的项目的依赖项,如下所示:

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>3.0.8.Final</version>
</dependency>

我可以正常编写代码,但是当我尝试编译时,出现以下错误:

java: cannot access javax.ws.rs.client.ClientBuilder
  class file for javax.ws.rs.client.ClientBuilder not found

java: cannot access javax.ws.rs.core.Link
  class file for javax.ws.rs.core.Link not found

java: cannot access javax.ws.rs.client.WebTarget
  class file for javax.ws.rs.client.WebTarget not found

尽管我可以正常找到这些类,但我知道它们在我的Maven存储库中,如果我使用IDE查找它们,则可以访问它们,因此我知道它们存在。

我尝试将依赖项范围更改为providedcompile只是为了对其进行测试,但是没有运气。

知道我可能会缺少什么吗?

编辑

相关的pom.xml

<modelVersion>4.0.0</modelVersion>

<artifactId>my-project-id</artifactId>
<name>MyProject Name</name>

<dependencies>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-client</artifactId>
        <version>3.0.8.Final</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>

类无法编译

import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
import my.project.representations.App;

public class Main {

    public static void main(String[] args) {

        ResteasyClient client = new ResteasyClientBuilder().build();
        ResteasyWebTarget target = client.target(SERVER_URL);

        String token = "access_token";

        target.register(new BearerTokenFilter(token));

        Admin admin = target.proxy(Admin.class);

        Realm realm = admin.realm("realm_name");

        for (App app : realm.apps().findAll()) {
            System.out.println(app.getName());
        }

    }

}
用户177800

您没有包括对它所抱怨的依赖项:

这是API类的位置:

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0</version>
</dependency>

search.maven.org是您的朋友!

以下内容也不正确。

您已经标记了所需的resteasy-client.jar依赖关系以及其他依赖关系,provided这意味着在执行或打包依赖关系时,它将不会包含在类路径中。

删除<scope>所有这些依赖项上元素,这很可能是不正确的。

查看<scope>元素文档,并确保这是您想要的。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

为什么编译器找不到我的方法?

来自分类Dev

代码块找不到我的编译器

来自分类Dev

NetBeans 找不到我的 Maven 依赖项

来自分类Dev

为什么编译器在有 2 个类的源文件中找不到我的公共类?

来自分类Dev

将Maven依赖项添加到我的Maven项目时找不到资源

来自分类Dev

Maven在Linux上找不到编译器

来自分类Dev

找不到TypeScript编译器

来自分类Dev

找不到C编译器,Ubuntu

来自分类Dev

找不到可用的C编译器

来自分类Dev

Qt找不到编译器

来自分类Dev

编译器找不到重载

来自分类Dev

.NET编译器找不到引用

来自分类Dev

编译器找不到.lib文件

来自分类Dev

编译器错误-找不到符号

来自分类Dev

编译器找不到符号

来自分类Dev

CMake找不到编译器

来自分类Dev

使找不到当前交叉编译器

来自分类Dev

Gradle在〜/ .ivy2 / local中找不到我的依赖项

来自分类Dev

Visual Studio Code + Java-从build.gradle.kts中找不到我的依赖项

来自分类Dev

Gradle在〜/ .ivy2 / local中找不到我的依赖项

来自分类Dev

Maven找不到某些依赖项的组件

来自分类Dev

在Android Studio中将Java模块作为依赖项包含错误的Java编译器

来自分类Dev

人偶找不到依赖项类

来自分类Dev

Eclipse找不到我的主类

来自分类Dev

使用反编译器的IntelliJ IDEA Maven依赖项资源代码

来自分类Dev

Tycho编译器无法从插件依赖项中找到类

来自分类Dev

Maven 插件依赖:找不到类

来自分类Dev

编译器错误-“错误:找不到或加载主类com.sun.tools.javac.Main”

来自分类Dev

当编译器说“在基类中找不到”时,如何覆盖方法?