I'm using Intellij to develop a Java project. However, I've been stuck in a annoying dependency problem. I'm trying to import:
import org.json.JSONException;
import org.json.simple.parser.ParseException;
But when I hit run, the compiler gives me the following errors:
Error:(23, 16) java: cannot find symbol
symbol: class JSONException
location: package org.json
Error:(34, 44) java: cannot find symbol
symbol: class JSONException
location: class com.test.util.metrics.ClientTest
At first it seems to be a typical maven dependency problem, but it turns out I still failed to solve it. I've tried:
1/ add json dependency to .xml file:
<java.version>1.8</java.version>
<jsonSimple.version>1.1</jsonSimple.version>
...
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>${jsonSimple.version}</version>
</dependency>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${mavenCompilerPlugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
...
2/ In Intellij, hit Maven and Reimport
3/ In Intellij, hit Maven and Generate Source and Update Folders
4/ In Intellij, hit Maven and Download Sources and Documentation
But none of the above 4 works, still the same error message.
Could anyone give me some suggestions on this? I know it's a daily problem, but I still cannot solve this... Thanks in advance.