简体   繁体   English

Maven Jar 库的项目存储库

[英]Maven Project Repository of Jar libraries

I'm trying to add Maven to already existing java project.我正在尝试将 Maven 添加到现有的 java 项目中。 It's been quite an adventure.这真是一次冒险。 I've read many questions here but I don't quite get it.我在这里阅读了很多问题,但我不太明白。 The app I'm building is kinda modular so I'm loading many classes from URL so that the need of replacing the.exe (wrapped jar) file is at its minimum (Cuz once opened by any user I'cant update - replace the app (.exe)).我正在构建的应用程序有点模块化,所以我从 URL 加载了许多类,以便替换 .exe(包装的 jar)文件的需求最小(因为任何用户打开后我无法更新 - 替换应用程序(.exe))。

Since I'm using wide variety of libraries and the app Jar, hense the.exe, became too large - ~80MB, and slow to open from fileshare.由于我使用了各种各样的库和应用程序 Jar,因此.exe 变得太大 - ~80MB,并且从文件共享打开速度很慢。 Hense the need of Maven (or so I think). Hense需要Maven(或者我认为)。 Since I installed Maven I had to add package statement at the top of every class, because before then there was not such thing, nor the need for it.由于我安装了 Maven 我不得不在每个 class 的顶部添加 package 语句,因为在此之前没有这样的东西,也不需要它。 Maven found the dependencies online and for the most part the process was not so time consuming, but the goal is to load the libraries from the project(app) folder /lib/. Maven 在线找到了依赖项,并且在大多数情况下该过程并不那么耗时,但目标是从项目(应用程序)文件夹 /lib/ 加载库。 There I have all the libraries in jar files that I need.那里有我需要的 jar 文件中的所有库。 My question is: Is there a need of installing the libraries to local m2 directory (as I've read) since the app should always load them from the app folder?我的问题是:是否需要将库安装到本地 m2 目录(如我所读),因为应用程序应始终从应用程序文件夹加载它们? How do I configure the POM so the project/lib/ directory is recognized as a repo (or even is this the right approach), and load the libraries from the relative path of the project folder?如何配置 POM 以便将 project/lib/ 目录识别为 repo(甚至这是正确的方法),并从项目文件夹的相对路径加载库? Thanks in advance to anyone able and willing to help!提前感谢任何有能力并愿意提供帮助的人!

Maven's core objective is to manage dependencies. Maven 的核心目标是管理依赖关系。 You can add a dependency to your project, by configuring it in pom.xml, maven will download the dependency from the maven central repository & when building the project, maven can help you create a runnable JAR that have all your dependencies & code compiled. You can add a dependency to your project, by configuring it in pom.xml, maven will download the dependency from the maven central repository & when building the project, maven can help you create a runnable JAR that have all your dependencies & code compiled.

Let's say in your current project if all of the dependencies are absolutely necessary, then even after migrating the project to maven, you're runnable JAR will remain the same size.假设在您当前的项目中,如果所有依赖项都是绝对必要的,那么即使在将项目迁移到 maven 之后,您仍可运行 JAR 将保持相同的大小。 There won't be any reduction in your application size.您的应用程序大小不会有任何减少。 However, I would highly recommend migrating your project to any build tool like gradle or maven to manage project dependencies.但是,我强烈建议将您的项目迁移到任何构建工具,如 gradle 或 maven 以管理项目依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM