'Unable to import JDA into Maven - IntelliJ IDEA
I need to import JDA dependency into my Maven (Java) project, yet IDEA doesn't seem to be able to import it for some reason. I did as following:
inside the pom.xml file:
<dependencies>
<!-- https://mvnrepository.com/artifact/net.dv8tion/JDA -->
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.11</version>
</dependency>
</dependencies>
Main class:
public class Main {
JDA bot = JDABuilder.createDefault("token");
public static void main(String[] args) {}
}
Importing doesn't work for some reason. I wrote this:
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
I tried various methods how to resolve this, like manually downloading source, javadoc, and jar files from the website (not all of them though). Also I'm using Maven 3, if that could be a potential mistake.
I don't have much experience with Maven or importing dependencies overall, so I feel kind of lost at the moment. I've wanted to do the beginning of the code like in this tutorial I was following step by step up until this moment. Would appreciate any help I can get. Thanks!
Edit:
I also tried running it on a different PC, still getting the same error though.
Solution 1:[1]
The issue seems to have been my own error, that I didn't have a repository in the pom.xml file. All it took was to add it and it worked when I reloaded the file.
<dependencies>
<!-- https://mvnrepository.com/artifact/net.dv8tion/JDA -->
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.11</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>dv8tion</id>
<name>m2-dv8tion</name>
<url>https://m2.dv8tion.net/releases</url>
</repository>
</repositories>
Thanks everyone for your help!
Solution 2:[2]
After pasting a dependency in pom.xml on right corner screen maven reload button will be shown press that button and check
Or
Try: File -> Invalidate Caches... -> Check Clear file system cache and Local History also -> Press Invalidate and Restart.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Vojt?ch |
Solution 2 |