V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
seedhk
V2EX  ›  Java

请教一个 maven deploy jar 包失败的问题

  •  
  •   seedhk · 23 天前 · 738 次点击

    idea 版本:2023.3.2 maven 版本:3.6.1

    自己通过 nexus+docker 在服务器上搭了一个 maven 私服,想把自己的依赖包 deploy 到私服上,出现了如下错误:

    报错信息:

        at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
        at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
    Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
          role: org.apache.maven.wagon.Wagon
      roleHint: >http
        at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:267)
        at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:255)
    
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:3.0.0:deploy-file (deploy-file) on project by-framework: Failed to deploy artifacts/metadata: Cannot access >http://0.0.0.0:7000/repository/maven-snapshots/ with type default using the available connector factories: BasicRepositoryConnectorFactory: Cannot access >http://0.0.0.0:7000/repository/maven-snapshots/ using the registered transporter factories: WagonTransporterFactory: java.util.NoSuchElementException
    [ERROR]       role: org.apache.maven.wagon.Wagon
    [ERROR]   roleHint: >http
    [ERROR] -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:3.0.0:deploy-file (deploy-file) on project by-framework: Failed to deploy artifacts/metadata: Cannot access >http://0.0.0.0:7000/repository/maven-snapshots/ with type default using the available connector factories: BasicRepositoryConnectorFactory
    
    Caused by: org.eclipse.aether.transfer.NoRepositoryConnectorException: Cannot access >http://0.0.0.0:7000/repository/maven-snapshots/ with type default using the available connector factories: BasicRepositoryConnectorFactory
    
    Caused by: java.util.NoSuchElementException
        at org.eclipse.sisu.plexus.RealmFilteredBeans$FilteredItr.next (RealmFilteredBeans.java:118)
        at org.eclipse.sisu.plexus.RealmFilteredBeans$FilteredItr.next (RealmFilteredBeans.java:1)
        at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next (DefaultPlexusBeans.java:76)
        at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next (DefaultPlexusBeans.java:1)
    
    

    包信息:

    <modelVersion>4.0.0</modelVersion>
        <parent> 
            <groupId>org.springframework.boot</groupId> 
            <artifactId>spring-boot-starter-parent</artifactId> 
            <version>2.5.7</version> 
            <relativePath/> 
        </parent>
    <groupId>com.xxxxx</groupId>
    <artifactId>framework</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <name>framework</name>
    

    依赖: .....省略业务依赖

    <dependency>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-component-metadata</artifactId> 
        <version>2.0.0</version>
    </dependency>
    

    pom 文件的配置项:

    <build> 
        <plugins> 
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>maven-compiler-plugin</artifactId> 
                <version>3.6.1</version>
                <configuration> 
                    <source>1.8</source> 
                    <target>1.8</target>
                    <fork>true</fork> 
                </configuration> 
            </plugin> 
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>maven-source-plugin</artifactId> 
                <executions> 
                    <execution> 
                        <id>attach-sources</id> 
                        <phase>verify</phase> 
                        <goals> 
                            <goal>jar-no-fork</goal> 
                        </goals>
                    </execution> 
                </executions> 
            </plugin> 
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>maven-deploy-plugin</artifactId> 
                <version>3.0.0</version> 
                <executions> 
                    <execution> 
                        <id>default-deploy</id> 
                        <phase>deploy</phase> 
                        <goals> 
                            <goal>deploy</goal> 
                        </goals> 
                        <configuration> 
                            <skip>true</skip> 
                        </configuration> 
                    </execution> 
                    <execution> 
                        <id>deploy-file</id> 
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy-file</goal> 
                        </goals> 
                        <configuration>
                            <repositoryId>${project.distributionManagement.snapshotRepository.id}</repositoryId> 
                            <url>${project.distributionManagement.snapshotRepository.url}</url> 
                            <file>${project.build.directory}/${project.build.finalName}.jar</file>
                            <groupId>${project.groupId}</groupId> 
                            <artifactId>${project.artifactId}</artifactId> 
                            <version>${project.version}</version> 
                        </configuration> 
                    </execution> 
                </executions> 
            </plugin> 
        </plugins>
    </build>
    
    
    <distributionManagement> 
        <repository> 
            <id>nexus-releases</id> 
            <name>artifactory-releases</name> 
            <url>http://0.0.0.0::7000/repository/maven-releases/</url>
        </repository> 
        <snapshotRepository> 
            <id>nexus-snapshots</id> 
            <name>artifactory-snapshots</name> 
            <url>>http://0.0.0.0:7000/repository/maven-snapshots/</url> 
        </snapshotRepository>
    </distributionManagement>
    <repositories> 
        <repository> 
            <id>maven-releases</id> 
            <name>User Porject Release</name> 
            <url>http://0.0.0.0:7000/repository/maven-releases/</url>
        </repository> 
        <repository> 
            <id>maven-snapshots</id> 
            <name>User Porject Snapshot</name> 
            <url>http://0.0.0.0:7000/repository/maven-snapshots/</url> 
        </repository>
    </repositories>
    
    

    maven 的 setting.xml 文件配置:

    <servers>
             <server>
                <id>nexus</id>
                <username>admin</username>
                <password>****</password>
            </server>
            <server>
                <id>nexus-releases</id>
                <username>admin</username>
                <password>****</password>
            </server>
            <server>
                <id>nexus-snapshots</id>
                <username>admin</username>
                <password>****</password>
            </server>
        </servers>
        
        <mirrors>
            <mirror>
                <id>mymaven</id>
                <name>my maven</name>
                <url>http://0.0.0.0:7000/repository/maven-public/</url>
                <mirrorOf>*</mirrorOf>
            </mirror>
            
            
     <profiles>
            <profile>
              <id>nexus</id>
              <repositories>
                <repository>
                    <id>release</id>
                    <url>http://0.0.0.0:7000/repository/maven-releases/</url>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy> 
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                </repository>
                <repository>
                    <id>snapshot</id>
                    <url> http://0.0.0.0:7000/repository/maven-snapshots/</url>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy> 
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                </repository>
              </repositories>
              <pluginRepositories>
                <pluginRepository>
                    <id>release</id>
                    <url>http://0.0.0.0:7000/repository/maven-releases/</url>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                </pluginRepository>
                <pluginRepository>
                    <id>snapshot</id>
                    <url> http://0.0.0.0:7000/repository/maven-snapshots/</url>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                </pluginRepository>
              </pluginRepositories>
            </profile>
        </profiles>
        <activeProfiles>
            <activeProfile>nexus</activeProfile>
        </activeProfiles>
    
    10 条回复    2024-04-08 08:40:04 +08:00
    hnliuzesen
        1
    hnliuzesen  
       23 天前
    这个 0.0.0.0:7000 的地址执行 deploy 命令的机器用浏览器能访问么?
    seedhk
        2
    seedhk  
    OP
       23 天前
    @hnliuzesen 可以的,maven 包的下载正常
    perfectlife
        3
    perfectlife  
       23 天前
    我还是感觉你这个 0.0.0.0:7000 这个地址比较怪
    seedhk
        4
    seedhk  
    OP
       23 天前
    @perfectlife 原本是真实的服务器 IP 地址,被我隐藏成了 0.0.0.0
    Kaiv2
        5
    Kaiv2  
       23 天前
    repository id 配置错误
    Kaiv2
        6
    Kaiv2  
       23 天前
    还有,maven 好像后 3.7/ 8.xx 后面的版本必须使用 https 了
    seedhk
        7
    seedhk  
    OP
       23 天前
    @Kaiv2 repository id 配置错误 请问具体指的是哪里。
    maven 目前用的是 3.6.1
    xuyang2
        8
    xuyang2  
       23 天前
    maven 是开源的,
    mvn deploy 也是可以用 IDE debug 的

    https://stackoverflow.com/questions/14602540/how-to-debug-a-maven-goal-with-intellij-idea
    xiaokongwu
        9
    xiaokongwu  
       23 天前
    多了个 ">"……

    seedhk
        10
    seedhk  
    OP
       22 天前
    @xiaokongwu 感谢大佬,确实是。我之前也注意到了这个 > 但是只检查了 setting.xml 文件,没检查 pom 文件。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2549 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 11:29 · PVG 19:29 · LAX 04:29 · JFK 07:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.