The import io.restassured.RestAssured cannot be resolved

筅森魡賤 提交于 2021-01-27 14:42:11

问题


Hi I am not able to resolve the error while using rest assured 4.1.1. library in my Eclipse IDE. I have added the rest assured library in my pom.xml file still the error is not resolved.

I tried re-importing the rest assured library from https://mvnrepository.com/artifact/io.rest-assured/rest-assured/4.1.1 But still doesn't work

<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>RestAssuredTutorial</groupId>
<artifactId>RestAssuredTutorial</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
  <dependency>
      <groupId>io.rest-assured</groupId>
      <artifactId>rest-assured</artifactId>
      <version>4.1.1</version>
      <scope>test</scope>
  </dependency>
 <!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json- 
 simple -->
<dependency>
    <groupId>com.googlecode.json-simple</groupId>
    <artifactId>json-simple</artifactId>
    <version>1.1.1</version>
  </dependency>
  <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
    <dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.8.6</version>
 </dependency>

 </dependencies>
</project>

The import io cannot be resolved


回答1:


You have the scope set to test when you are adding the mentioned dependency. This limits your code from accessing that dependency's classes within your source code. That is, you can access those classes only within your test sources (ex: ${project.dir}/src/test/java/<package>, ${project.dir}/test/<package>.

If that is not your intended use case, just remove the scope attribute.

  <dependency>
      <groupId>io.rest-assured</groupId>
      <artifactId>rest-assured</artifactId>
      <version>4.1.1</version>
  </dependency>


来源:https://stackoverflow.com/questions/58515714/the-import-io-restassured-restassured-cannot-be-resolved

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!