Home  >  Q&A  >  body text

java - maven 私服同步有没有可能出错

环境:公司的 maven 私服

项目中引入了 rocketmq-client 3.2.6 依赖,
在 http://search.maven.org/ 中查找此 jar 的 pom 文件为:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>com.alibaba.rocketmq</groupId>
        <artifactId>rocketmq-all</artifactId>
        <version>3.2.6</version>
    </parent>
 
    <modelVersion>4.0.0</modelVersion>
    <packaging>jar</packaging>
    <artifactId>rocketmq-client</artifactId>
    <name>rocketmq-client ${project.version}</name>
 
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>rocketmq-common</artifactId>
        </dependency>
    </dependencies>
</project>

但是公司私服中此 jar 的 pom 文件为

图好像挂了,直接发代码吧

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.alibaba.rocketmq</groupId>
  <artifactId>rocketmq-client</artifactId>
  <version>3.2.6</version>
  <description>POM was created by Sonatype Nexus</description>
</project>

上段代码显示没有任何依赖项,所以 maven 没有去下载 rocketmq-client 依赖的 rocketmq-common ... ,进而导致项目报错。

那么问题来了:

  1. maven 私服同步的时候回导致同步失败吗 ? 会什么会出现同步后的 pom 不同的情况?

  2. 既然按照私服中的 pom 依赖为准, 那为什么我手动在本地仓库中加了相关 jar 后,使用 jetty 插件 run 时却能正常启动 ?

ringa_leeringa_lee2764 days ago328

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 18:03:25

    This jar should not be synchronized with the remote warehouse normally, you can add it manually.
    If you add the jar manually, the jar will generally contain the pom.xml file, and the warehouse will automatically import it, so there will be no problem when you run it.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 18:03:25

    You can add it manually. Today I am still adding packages manually because the company network is not working. . fk..
    mvn install:install-file -Dfile=jasperreports-customvisualization-6.2.1.jar -DgroupId=com.jaspersoft.jasperreports -DartifactId=jasperreports-customvisualization -Dversion=6.2.1 -Dpackaging=jar

    reply
    0
  • Cancelreply