代码之家  ›  专栏  ›  技术社区  ›  Sugan

放心进口不解决

  •  0
  • Sugan  · 技术社区  · 6 年前

    我已经包括放心罐在我的POM如下。

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

    但import语句仍然显示“import io无法解析”。如果我下载rest-assured jar并将它们手动添加为外部jar,错误就会消失。

    import static io.restassured.RestAssured.*;
    import static org.hamcrest.Matchers.*;
    

    我试着把它取下来

    <scope>test</test> 
    

    标签也建议在一些网站。这并不能解决问题。

    import static io.restassured.RestAssured.*;
    import static org.hamcrest.Matchers.*;
    
    import org.testng.annotations.BeforeClass;
    import org.testng.annotations.Test;
    
    import io.restassured.RestAssured;
    
    public class OpenURL {
    
        @BeforeClass
        public void initPath() {
    
            RestAssured.baseURI = "http://localhost:9876";
        }
    
        /*******************************************************
         * Send a GET request to /api/f1/2016/drivers.json
         * and check that the answer has HTTP status code 200 
         ******************************************************/
    
        @Test
        public void checkResponseCodeForCorrectRequest() {
    
            given().
            when().
                get("/api/f1/2016/drivers.json").
            then().
                assertThat().
                statusCode(200);
        }
    }
    

    <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>REST</groupId>
      <artifactId>REST</artifactId>
      <version>0.0.1-SNAPSHOT</version>
       <dependencyManagement>
        <dependencies>
            <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>rest-assured</artifactId>
        <version>3.0.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.9.10</version>
     </dependency>
    
                    <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-all</artifactId>
                <version>2.4.5</version>
            </dependency>
            </dependencies>
              </dependencyManagement>
    </project>
    
    1 回复  |  直到 5 年前
        1
  •  4
  •   Wilfred Clement    6 年前

    “我怀疑” 依赖管理 “泰格,你能试试下面的吗

      <version>0.0.1-SNAPSHOT</version>
              <dependencies>
                <dependency>
                    <groupId>io.rest-assured</groupId>
                    <artifactId>rest-assured</artifactId>
                    <version>3.0.0</version>
                </dependency>
                <!-- https://mvnrepository.com/artifact/org.testng/testng -->
                <dependency>
                    <groupId>org.testng</groupId>
                    <artifactId>testng</artifactId>
                    <version>6.9.10</version>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-all</artifactId>
                    <version>2.4.5</version>
                </dependency>
            </dependencies>
    </project>
    
        2
  •  1
  •   user1053540    5 年前

    http://maven.apache.org/xsd/maven-4.0.0.xsd“> 4.0.0

    <groupId>com.student.app</groupId>
    <artifactId>PaypalExmaples</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    
    <name>PaypalExmaples</name>
    <url>http://maven.apache.org</url>
    
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    
    <dependencies>
    
        <!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>4.1.2</version>
            <scope>test</scope>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/org.testng/testng -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.1.0</version>
            <scope>test</scope>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-all -->
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy -->
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy</artifactId>
            <version>2.5.9</version>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.11</version>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.3.1</version>
        </dependency>
    
    
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.9</version>
        </dependency>
    
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured-all</artifactId>
            <version>4.0.0</version>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.10.2</version>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all -->
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.5.9</version>
            <type>pom</type>
        </dependency>
    
        <dependency>
            <groupId>org.skyscreamer</groupId>
            <artifactId>jsonassert</artifactId>
            <version>1.5.0</version>
            <scope>test</scope>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.6</version>
        </dependency>
    
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.10.0.pr2</version>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/org.scribe/scribe -->
        <dependency>
            <groupId>org.scribe</groupId>
            <artifactId>scribe</artifactId>
            <version>1.3.7</version>
        </dependency>
    
    
    </dependencies>
    

        3
  •  -1
  •   David Buck Richard Ferris    5 年前
    import static io.restassured.RestAssured.*;
    import static org.hamcrest.Matchers.*;
    

    为我工作。这里我不使用POM文件