简体   繁体   English

获取包javax.ws.rs不存在错误

[英]Getting package javax.ws.rs does not exist error

I keep getting the javax.ws.rs error while my dependencies should be right. 我的依存关系应该正确的同时,我不断收到javax.ws.rs错误。 How do I fix this? 我该如何解决?

I am using the IntelliJ IDE and when I import it in my project it does recognise javax.ws.rs.*. 我正在使用IntelliJ IDE,当我将其导入到项目中时,它确实可以识别javax.ws.rs。*。 It does not give any error there. 那里没有任何错误。

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
</properties>


<dependencies>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>5.2.6.Final</version>
    </dependency>
    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>persistence-api</artifactId>
        <version>1.0.2</version>
    </dependency>
    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>javax.ws.rs-api</artifactId>
        <version>2.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.johnzon</groupId>
        <artifactId>johnzon-jaxrs</artifactId>
        <version>0.9.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-jaxrs</artifactId>
        <version>1.9.13</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.johnzon</groupId>
        <artifactId>johnzon-jaxrs</artifactId>
        <version>1.1.7</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.44</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.192</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.github.binout</groupId>
        <artifactId>jaxrs-unit-api</artifactId>
        <version>1.1.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.github.binout</groupId>
        <artifactId>jaxrs-unit-resteasy</artifactId>
        <version>1.1.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

Yes, your dependencies seem to be right. 是的,您的依赖关系似乎是正确的。

Try to update Idea's Maven indices as described here . 尝试按照此处所述更新Idea的Maven索引。 Go to Preferences and type into search box Repositories than find it under Maven section, select remote repo in the table and press update button. 转到“首选项”并在搜索框中键入“ Repositories ,然后在“ Maven”部分下找到它,在表中选择远程Repositories ,然后按“更新”按钮。

You might run then into another problem, when it takes infinite time to update indices('processing indices' phase takes minutes at any case) - just use this answers to fix the issue. 当您花费无限时间更新索引时(在任何情况下,“处理索引”阶段都需要几分钟的时间),您可能会遇到另一个问题-只需使用此答案即可解决问题。 To give more memory you can use Help->Edit Custom VM Options and set xmx to something like 2g 提供更多内存,您可以使用“帮助”->“编辑自定义VM选项”并将xmx设置为2g

The problem was that my project was in my OneDrive location. 问题是我的项目在我的OneDrive位置。 This caused me a lot of trouble but as soon as I moved it to my local drive it solved all of the problems. 这给我带来了很多麻烦,但是当我将其移至本地驱动器后,它就解决了所有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM