无法使用 Java 解决 IntelliJ 中 JSONArray 的符号错误

Cannot resolve symbol error for JSONArray in IntelliJ with Java

我在 IntelliJ 的 POM 文件中添加了以下内容(我使用的是 Maven)

     <dependency>
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>1.1</version>
     </dependency>

但是对于我的代码,在创建 "JSONArray" 对象时出现无法解析符号错误。

我试过使用 导入 org.json.jsonarray 和 导入 org.json.simple.jsonarray

我退出了 IntelliJ 并重建了项目。我不明白我做错了什么。

 public class Countries {

   private static String url;
   private static int count;
   private static int sCode;
   private static List<CountriesData> cList;

  public void GetCountries() throws Exception
   {
      try        {
         url = "http://restcountries.eu/rest/v1/all";

         // make get request to fetch json response from restcountries
         Response resp = get(url);

         //Fetching response in JSON as a string then convert to JSON Array
         JSONArray jsonResponse = new JSONArray(resp.asString());

运行 "File | Invalidate Caches" 在这种情况下有所帮助。