The import io.restassured.RestAssured cannot be resolved

While consuming restassured maven dependencies it has been observed that even after downloading the dependencies eclipse is not able to resolve io.restassured package.

Maven repository (https://mvnrepository.com/artifact/io.rest-assured/rest-assured) has the scope set to test in the dependency tag. 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/, ${project.dir}/test/.

Mostly that is not the intended use case, so just remove the scope attribute.

<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>4.3.2</version>
    <!-- <scope>test</scope> -->
</dependency>

3 thoughts on “The import io.restassured.RestAssured cannot be resolved

  1. Dirk says:

    I get a message “cannot access io.restassured.common.mapper.TypeRef” even though I only use it in my test classes.
    Currently using version 4.4.0

    1. Dirk says:

      You may not load both dependencies with artifactId rest-assured and spring-web-test-client.

  2. kumar says:

    <!– test –>, it works.

Leave a Reply to Dirk Cancel reply

Your email address will not be published. Required fields are marked *