我有一个由几个 Maven 模块组成的服务器项目。我现在正要创建另一个对象,它应该包含服务器和任何(Java)客户端共享的对象。看来,由于 Maven 依赖性,它希望我提供一个 .jar
文件。
在我的 pom.xml
中,我得到:
Missing artifact com.server:shared:jar:0.0.1-SNAPSHOT
如何告诉 Eclipse 创建一个 .jar
文件并将其复制到需要的位置,或者至少应该依赖源代码?
我的项目结构:
server (parent)
- server-data-model (maven-archetype-quickstart)
- server-web (maven-archetype-webapp)
- server-mobile (maven-archetype-webapp)
- server-shared (maven-archetype-quickstart)
server-web
和 server-mobile
只是提供 REST API,我想要做的是创建一个 jar
文件server-shared
用于服务器项目和另一个客户端项目共享。它包含基本上简单的 POJO 对象(客户端应该从服务器接收返回值)。
最佳答案
来自stackoverflow答案:
将 JAR 安装到本地 Maven 存储库中,如下所示:
mvn install:install-file
-Dfile=<path-to-file>
-DgroupId=<group-id>
-DartifactId=<artifact-id>
-Dversion=<version>
-Dpackaging=<packaging>
-DgeneratePom=true
Where: <path-to-file> the path to the file to load
<group-id> the group that the file should be registered under
<artifact-id> the artifact name for the file
<version> the version of the file
<packaging> the packaging of the file e.g. jar
更新
使用maven非常简单。
只需在 server-web
和 server-mobile
中添加依赖项,如下所示。
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>server-shared</artifactId>
<version>${project.version}</version>
</dependency>
关于java - Eclipse:Maven 模块缺少 Artifact - .jar 未创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30005928/