javadependenciespom.xmlrest-assuredrest-assured-jsonpath

The import io.restassured.RestAssured cannot be resolved


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


Solution

  • 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>