Tengo un problema. Creé 2 proyectos MAVEN y copié tanto las carpetas para mi servidor Ubuntu. Cuando quiero mvn package programa A, que ha incluido la dependencia del Proyecto B (simulador):

<dependency>
  <groupId>com.simulator</groupId>
  <artifactId>simulator</artifactId>
  <version>1.0-SNAPSHOT</version>
</dependency>

Dice:

[ERROR] Failed to execute goal on project hatop: Could not resolve dependencies                                                                             for project com.hatop:hatop:jar:1.0-SNAPSHOT: Could not find artifact com.simula                                                                            tor:simulator:jar:1.0-SNAPSHOT -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o                                                                            n project hatop: Could not resolve dependencies for project com.hatop:hatop:jar:                                                                            1.0-SNAPSHOT: Could not find artifact com.simulator:simulator:jar:1.0-SNAPSHOT
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDepend                                                                            encies (LifecycleDependencyResolver.java:269)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolvePr                                                                            ojectDependencies (LifecycleDependencyResolver.java:147)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreRes                                                                            olved (MojoExecutor.java:248)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja                                                                            va:202)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja                                                                            va:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja                                                                            va:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (                                                                            LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (                                                                            LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreaded                                                                            Builder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleSt                                                                            arter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccesso                                                                            rImpl.java:64)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMetho                                                                            dAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launche                                                                            r.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:2                                                                            25)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launc                                                                            her.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347                                                                            )
Caused by: org.apache.maven.project.DependencyResolutionException: Could not res                                                                            olve dependencies for project com.hatop:hatop:jar:1.0-SNAPSHOT: Could not find a                                                                            rtifact com.simulator:simulator:jar:1.0-SNAPSHOT
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve (Defa                                                                            ultProjectDependenciesResolver.java:209)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDepend                                                                            encies (LifecycleDependencyResolver.java:243)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolvePr                                                                            ojectDependencies (LifecycleDependencyResolver.java:147)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreRes                                                                            olved (MojoExecutor.java:248)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja                                                                            va:202)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja                                                                            va:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja                                                                            va:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (                                                                            LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (                                                                            LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreaded                                                                            Builder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleSt                                                                            arter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccesso                                                                            rImpl.java:64)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMetho                                                                            dAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launche                                                                            r.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:2                                                                            25)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launc                                                                            her.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347                                                                            )
Caused by: org.eclipse.aether.resolution.DependencyResolutionException: Could no                                                                            t find artifact com.simulator:simulator:jar:1.0-SNAPSHOT
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependenc                                                                            ies (DefaultRepositorySystem.java:357)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve (Defa                                                                            ultProjectDependenciesResolver.java:202)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDepend                                                                            encies (LifecycleDependencyResolver.java:243)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolvePr                                                                            ojectDependencies (LifecycleDependencyResolver.java:147)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreRes                                                                            olved (MojoExecutor.java:248)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja                                                                            va:202)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja                                                                            va:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja                                                                            va:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (                                                                            LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (                                                                            LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreaded                                                                            Builder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleSt                                                                            arter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccesso                                                                            rImpl.java:64)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMetho                                                                            dAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launche                                                                            r.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:2                                                                            25)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launc                                                                            her.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347                                                                            )
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not                                                                             find artifact com.simulator:simulator:jar:1.0-SNAPSHOT
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (Default                                                                            ArtifactResolver.java:424)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts                                                                             (DefaultArtifactResolver.java:229)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependenc                                                                            ies (DefaultRepositorySystem.java:340)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve (Defa                                                                            ultProjectDependenciesResolver.java:202)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDepend                                                                            encies (LifecycleDependencyResolver.java:243)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolvePr                                                                            ojectDependencies (LifecycleDependencyResolver.java:147)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreRes                                                                            olved (MojoExecutor.java:248)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja                                                                            va:202)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja                                                                            va:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja                                                                            va:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (                                                                            LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (                                                                            LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreaded                                                                            Builder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleSt                                                                            arter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccesso                                                                            rImpl.java:64)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMetho                                                                            dAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launche                                                                            r.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:2                                                                            25)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launc                                                                            her.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347                                                                            )
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find                                                                             artifact com.simulator:simulator:jar:1.0-SNAPSHOT
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (Default                                                                            ArtifactResolver.java:414)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts                                                                             (DefaultArtifactResolver.java:229)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependenc                                                                            ies (DefaultRepositorySystem.java:340)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve (Defa                                                                            ultProjectDependenciesResolver.java:202)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDepend                                                                            encies (LifecycleDependencyResolver.java:243)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolvePr                                                                            ojectDependencies (LifecycleDependencyResolver.java:147)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreRes                                                                            olved (MojoExecutor.java:248)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja                                                                            va:202)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja                                                                            va:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.ja                                                                            va:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (                                                                            LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (                                                                            LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreaded                                                                            Builder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleSt                                                                            arter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccesso                                                                            rImpl.java:64)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMetho                                                                            dAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launche                                                                            r.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:2                                                                            25)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launc                                                                            her.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347                                                                            )

Ya he empaquetado el proyecto Simulator, por lo que hay un archivo .jar en la carpeta de destino de ese paquete. Ejecutarlo en código visual en My Windows Desktop funciona bien y el proyecto se envasó. ¿Qué está causando esto y cómo puedo arreglar esto?

0
A. Vreeswijk 8 jun. 2021 a las 21:37

2 respuestas

La mejor respuesta

Necesitas ejecutar mvn install en la dependencia primero.

1
J Fabian Meier 8 jun. 2021 a las 18:47

Ejecutar mvn package solo genera el frasco en la carpeta target en este proyecto.

Sin embargo, para poder usar este frasco a través del mecanismo de dependencia en otro proyecto, debe poner en un lugar donde Maven lo espera: se llama un repositorio de Maven.

Tienes un repositorio local de Maven en $HOME/.m2/repository por ejemplo. También hay repositorios remotos (Maven Central) donde las bibliotecas públicas están disponibles, por ejemplo.

Por lo tanto, tiene que poner el archivo jar de su proyecto en un repositorio.

¿Como hacer eso?

para publicarlo en su repositorio local, simplemente puede ejecutar mvn install en lugar de mvn package.

1
Gaël J 8 jun. 2021 a las 18:50