亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

org.glassfish.jersey.server.ContainerException:

org.glassfish.jersey.server.ContainerException:

守著星空守著你 2022-11-30 13:20:08
我在 Eclipse 中有一個項目,它是一個WebService項目 REST API,我還在其中添加了另一個項目,Configure Build path -> Add Project并且在我的 API 方法中添加了另一個項目,我正在調用TestNGCreator類,請看下面。基本上這個項目使用 java 中的 jersey 框架創建 REST API,當我調用任何特定方法時,即執行它將調用另一個駐留在另一個項目中的類,我在這個項目的構建路徑中添加了項目,我的其他方法工作正常但是當我我從不同的項目調用方法我有這個錯誤。我是否需要在 POM.xml 或其他地方聲明一些我正在使用此類和此方法的地方我需要通過調用它來運行自動化TestNGCreator.main(null); 我的另一個項目是 javaTestNGCreator類中的自動化項目駐留在自動化項目中。通過調用此方法我需要調用上面的類并且當我這樣做時我收到錯誤。文件:Resource.java      @POST      @Path("/execute")      @Consumes(MediaType.APPLICATION_JSON)      @Produces(MediaType.APPLICATION_JSON)      public Response executeScript(String data) throws JSONException        {               ArrayList<Object> testCases = new ArrayList<Object>();            JSONArray jsonArray = new JSONArray();            JSONObject json = new JSONObject(data);            String configFile = (String) json.get("ConfigFiles");            String sheetName = (String) json.get("Sheetname");            jsonArray = (JSONArray) json.get("testCases");            for (int i = 0 ; i < jsonArray.length() ; i++)            {                testCases.add(jsonArray.get(i));            }            try {                TestNGCreator.main(null); //here  i am calling that class main method            } catch (IOException e) {                // TODO Auto-generated catch block                e.printStackTrace();            }            Response response = null;            System.out.println(jsonArray);            System.out.println(testCases);            return response;        }
查看完整描述

1 回答

?
哈士奇WWW

TA貢獻1799條經驗 獲得超6個贊

我在你的 pom 文件中沒有看到 test-ng 依賴項。請添加以下內容并嘗試。


<dependency>

    <groupId>org.testng</groupId>

    <artifactId>testng</artifactId>

    <version>6.10</version>

    <scope>test</scope>

</dependency>


查看完整回答
反對 回復 2022-11-30
  • 1 回答
  • 0 關注
  • 369 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號