在 Maven 中处理服务器 JAR
我的项目中有一些服务器 jar,我想将其迁移到 maven ..
我没有知道如何将依赖项附加到这些 jars.. 几乎有 24 个 jars.. 那么如何将它们添加到项目范围
There are some server jars in my project which i want to migrate to maven ..
I don't have any idea how can i have dependencies attached to these jars.. there are almost 24 jars.. So how can add them to the project scope
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以采取的方法取决于您是否有权访问这些“服务器”jar 的源。如果您这样做,那么没有什么可以阻止您创建一个/多个 Maven 项目、打包这些项目并将它们部署到您的 Maven 存储库中。
如果您无权访问源代码,并且官方 Maven 存储库中尚未提供这些源代码,那么您所能做的就是使用 maven install 将它们放入您的 Maven 存储库中:
mvn install:install-file -Dfile=<文件路径> -DgroupId=<组ID>; \-Dversion=<版本>; -Dpackaging=<包装>
-DartifactId=
完成所有这些
jar 后,只需将依赖项添加到您的项目中即可。
The approach you can take depends on whether you have access to the sources of those 'server' jars or not. If you do, then nothing prevents you from creating one/more Maven projects, packaging these and deploying them in your Maven repository.
If you don't have access to the sources and these aren't already available in official Maven repositories, then all you can do is put those in your Maven repository by using maven install:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
Once done for all of these jars, just add dependencies to your project.
我不建议您在 POM 中添加服务器 jar,而我只使用 API jar。
优点是您符合可移植标准。 M2E 将正确编译内容,并且在部署到运行时时(只要它支持 API),它仍然可以正确运行您的应用程序。
如果您想明确地查看它,您可以通过转到项目首选项然后转到目标运行时来添加运行时。您只需在 EAR 上执行此操作,它就会为您执行 EAR 中包含的项目。添加目标运行时的优点是 Eclipse 可以针对您的服务器进行额外的验证。
I don't recommend you add the server jars in your POM, instead I just use the API jar
The advantage is you are conforming to a portable standard. M2E will compile things correctly and it will still run your application correctly when deployed to the runtime provided it supports the API.
If you want to explicitly see it you can add the runtime by going to the project preferences then going to Targetted Runtimes. You only need to do it on the EAR it will do the included projects in the EAR for you. The advantage of adding the targetted runtime is Eclipse may do extra validation specific for your server.