[英]How do I add dependencies/3rd party java libraries into Maven for Intellij and/or VS Code?
I am trying to make a JSON parser for a project using GSON in java with Maven in Intellij or VS Code. I am trying to make a JSON parser for a project using GSON in java with Maven in Intellij or VS Code. Whenever I try to compile/run the debugger on the file (ex: javac jsonParser.java) it always says the "com.google.gson" and related objects such as "GSON gson = new Gson();"
每当我尝试在文件上编译/运行调试器(例如:javac jsonParser.java)时,它总是说“com.google.gson”和相关对象,例如“GSON gson = new Gson();” does not exist.
不存在。
Things I have tried:我尝试过的事情:
Watching many tutorials/read many walkthroughs on how to add a dependency/3rd party JAR, however, the best I was able to do was make the App.java file in a default Maven project template be able to use the GSON library, but any additional java files in the folder would still get the above compilation error. Watching many tutorials/read many walkthroughs on how to add a dependency/3rd party JAR, however, the best I was able to do was make the App.java file in a default Maven project template be able to use the GSON library, but any文件夹中的其他 java 文件仍然会出现上述编译错误。
Manually add the dependency information in the pom.xml file在 pom.xml 文件中手动添加依赖信息
TLDR: Would someone be able to walk me through adding a 3rd party library in Maven/Gradle and/or Intellij/VS Code? TLDR:有人可以指导我在 Maven/Gradle 和/或 Intellij/VS Code 中添加第 3 方库吗? If it helps, I am willing to use Gradle or some other (freely available) software if that is easier/preferred?
如果有帮助,我愿意使用 Gradle 或其他一些(免费提供)软件,如果这更容易/更喜欢? I am new to any sort of software development (first year CS student) so I have no experience in terms of making a completed project.
我对任何类型的软件开发都是新手(一年级 CS 学生),所以我没有完成项目的经验。
You look up the GSON coordinates (groupId, artifactId, version) in MavenCentral( http://search.maven.org )您在 MavenCentral ( http://search.maven.org ) 中查找 GSON 坐标(groupId、artifactId、version)
You take the XML from MavenCentral and copy it to the <dependencies>
section of your pom.xml
您从 MavenCentral 获取 XML 并将其复制到
pom.xml
的<dependencies>
部分
You use GSON in your Java code您在 Java 代码中使用 GSON
You build your project with mvn clean verify
您使用
mvn clean verify
构建您的项目
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.