Maven searches by default for artifacts in Maven Central.
I can find this artifact in Maven Central: http://search.maven.org/#artifactdetails%7Ccom.google.code.gson%7Cgson%7C2.3%7Cjar
In your settings.xml you tell maven which are the repos you wanna search in, if you have "special" repos. There, you can configure username/passwords for these repos in case you need to upload JARs to your repo.
So if your maven cannot find it, paste here your settings.xml - maybe it is misconfigured.
BTW: does this help? GSON is not being imported into the maven pproject
Answer from OhadR on Stack OverflowMaven searches by default for artifacts in Maven Central.
I can find this artifact in Maven Central: http://search.maven.org/#artifactdetails%7Ccom.google.code.gson%7Cgson%7C2.3%7Cjar
In your settings.xml you tell maven which are the repos you wanna search in, if you have "special" repos. There, you can configure username/passwords for these repos in case you need to upload JARs to your repo.
So if your maven cannot find it, paste here your settings.xml - maybe it is misconfigured.
BTW: does this help? GSON is not being imported into the maven pproject
Answer from OhadR on Stack OverflowVideos
Whenever I work on a project using Maven on VSC, I always get "[module name] cannot be resolved to a module". For example, in my project made using the JavaFX Template, only JavaFX works and when I try to load gson it does not work. It does not allow me to import or require any new dependency. This is when I add new dependencies through VSCs inbuilt add maven dependencies function.
My module-info.java
module com.example {
requires javafx.controls;
requires javafx.fxml;
opens com.example.controllers to javafx.fxml;
exports com.example;
exports com.example.controllers;
}My pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>maron</artifactId>
<version>1</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>13</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>13</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.6</version>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>com.example.App</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>I tried mvn clean install but it still does not work. I also updated maven too.
I've always had trouble running my maven projects that use Gson in the cmd line / terminal getting errors at runtime like:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/Gson
at controllers.CourseSchedulerController.findCorrectOrder(CourseSchedulerController.java:28)
at Scheduler.main(Scheduler.java:13)
I suppose IDEs like IntelliJ handle dependencies for you but there should be a way to add this dependency when I run from terminal right? These are the commands i'm running:
mvn clean install
mvn compile
mvn clean package
java -cp target/course_scheduler-1.0-SNAPSHOT.jar Scheduler