简体   繁体   English

使用Maven从pom.xml构建项目后,如何使用其资源

[英]After building the project from pom.xml using Maven, how do I use its resources

It's been tedious. 这很乏味。 This is the API I am trying to use. 这是我尝试使用的API Its resources were set up in a pom.xml which I built using Maven. 它的资源是在我使用Maven构建的pom.xml中设置的。 On built up, it gave me the project socrata-publisher that has 在建起来了,它给我的项目socrata出版商

  • src/main/java the source folder with packages com.socrata.api com.socrata.data , com.socrata.util where each contains only .java files src / main / java包含com.socrata.api com.socrata.datacom.socrata.util包的源文件夹,其中每个文件夹仅包含.java文件
  • JRE System Library and Maven Dependency hierarchies where each contains a number of jar files JRE系统库Maven依赖关系层次结构,其中每个包含许多jar文件

Problem is com.socrata.api and the 2 other contains classes which I want to deploy in a project outside socrata-publisher. 问题是com.socrata.api ,另外2个包含我想在socrata-publisher之外的项目中部署的类。 I tried using import com.socrata.api but it didn't work. 我尝试使用import com.socrata.api但是没有用。 Moreover, since its a Java project and not android it doesn't have the is Library option in preferences which could rather give me the solution. 而且,由于它是Java项目而不是android,因此它在首选项中没有is库选项,而这可能会给我解决方案。 Both socrata-publisher and tutorial (where i want to use the resources and which is the android application) lie in the same directory eclipseApps in My Documents. socrata-publishertutorial (我想在其中使用资源,并且是android应用程序)都位于“我的文档”中的eclipseApps目录中。

Here's a little visual queue. 这是一个视觉队列。 Help will be greatly appreciated. 帮助将不胜感激。

在此处输入图片说明

You will need to first of all get the output of the socrata project and all its dependencies. 您首先需要获取socrata项目及其所有依赖项的输出。

In command line, going to the project folder of the socrata project, where the pom.xml file is, run MVN INSTALL. 在命令行中,转到pom.xml文件所在的socrata项目的项目文件夹,运行MVN INSTALL。 You shall see a jar file called socrata-api.jar in $HOME/.m2/repository. 您将在$ HOME / .m2 / repository中看到一个名为socrata-api.jar的jar文件。 If you are using windows and installed MAVEN by default, $HOME should be your user profile folder. 如果您使用的是Windows,并且默认情况下已安装MAVEN,则$ HOME应该是您的用户配置文件文件夹。 Once you see the jar file, add it to your tutorial build path. 看到j​​ar文件后,将其添加到教程的构建路径中。

I think what you actually want to do is just set up the "socrata-publisher" as a project dependency for your "tutorial" project. 我认为您真正想做的只是将“ socrata-发布器”设置为“教程”项目的项目依赖项。 That will allow you to reference the built Socrata libraries from the code in your project. 这样您就可以从项目中的代码中引用构建的Socrata库。

Right click on the project and select "Properties". 右键单击该项目,然后选择“属性”。 From within that dialog select "Java Build Path" on the left, then the "Projects" section, and click the "Add" button to add the "socrata-publisher" project. 在该对话框中,选择左侧的“ Java构建路径”,然后选择“项目”部分,然后单击“添加”按钮以添加“ socrata-publisher”项目。

I think that'll work better than creating a separate jar file that you then include, and then you can also keep the socrata-publisher code up to date using Git. 我认为这比创建一个单独的jar文件(然后包含它)更好,然后您还可以使用Git使socrata-publisher代码保持最新。

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

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