Maven build error - Could not resolve dependencies for project

Asked

Viewed 8,637 times

1

This message appears on my Maven app

inserir a descrição da imagem aqui

I tried to build a Maven with the clean package command

[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building PedidoVenda 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://repository.primefaces.org/com/outjected/simple-email/0.1.2-SNAPSHOT/maven-metadata.xml
[INFO] Downloading: http://repository.primefaces.org/com/outjected/simple-email/0.1.2-SNAPSHOT/simple-email-0.1.2-SNAPSHOT.pom
[WARNING] The POM for com.outjected:simple-email:jar:0.1.2-SNAPSHOT is missing, no dependency information available
[INFO] Downloading: http://repository.primefaces.org/com/outjected/simple-email/0.1.2-SNAPSHOT/simple-email-0.1.2-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.442 s
[INFO] Finished at: 2015-06-27T18:34:09-03:00
[INFO] Final Memory: 7M/94M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project PedidoVenda: Could not resolve dependencies for project com.algaworks:PedidoVenda:war:1.0.0-SNAPSHOT: Could not find artifact com.outjected:simple-email:jar:0.1.2-SNAPSHOT in prime-repo (http://repository.primefaces.org) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

I wonder what’s going on?

And how to solve the problem?

Pom.xml

<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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.algaworks</groupId>
    <artifactId>PedidoVenda</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <!-- Implementacao do Bean Validation -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.0.1.Final</version>
            <scope>compile</scope>
        </dependency>

        <!-- Núcleo do Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.2.3.Final</version>
            <scope>compile</scope>
        </dependency>

        <!-- Implementação de EntityManager da JPA -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.2.3.Final</version>
            <scope>compile</scope>
        </dependency>

        <!-- Driver JDBC do MySQL -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.25</version>
            <scope>compile</scope>
        </dependency>

        <!-- Weld (implementação do CDI) -->
        <dependency>
            <groupId>org.jboss.weld.servlet</groupId>
            <artifactId>weld-servlet</artifactId>
            <version>1.1.10.Final</version>
            <scope>compile</scope>
        </dependency>

        <!-- PrimeFaces (biblioteca de componentes) -->
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>3.5</version>
            <scope>compile</scope>
        </dependency>

        <!-- Mojarra (implementacao do JSF) -->
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.faces</artifactId>
            <version>2.1.21</version>
            <scope>compile</scope>
        </dependency>

        <!-- OmniFaces (utilitarios para JSF) -->
        <dependency>
            <groupId>org.omnifaces</groupId>
            <artifactId>omnifaces</artifactId>
            <version>1.5</version>
            <scope>compile</scope>
        </dependency>

        <!-- Log4J -->      
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
            <scope>compile</scope>
        </dependency>

        <!-- Commons Logging (abstrai a implementação de logging) -->
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.3</version>
            <scope>compile</scope>
        </dependency>

        <!-- Commons Lang (utilidades) -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.1</version>
            <scope>compile</scope>
        </dependency>

        <!-- Abstração para envio de e-mails -->        
        <dependency>
            <groupId>com.outjected</groupId>
            <artifactId>simple-email</artifactId>
            <version>0.1.2-SNAPSHOT</version>
            <scope>compile</scope>
        </dependency>

        <!-- Requerido para envio de e-mails -->
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.7</version>
            <scope>compile</scope>
        </dependency>

        <!-- Usamos para templates de emails -->
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity</artifactId>
            <version>1.7</version>
            <scope>compile</scope>
        </dependency>

        <!-- Usamos para formatar números em templates -->
        <dependency>
            <groupId>velocity-tools</groupId>
            <artifactId>velocity-tools-generic</artifactId>
            <version>1.1</version>
            <scope>compile</scope>
        </dependency>

        <!-- Spring Security (autenticação e autorização) -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>3.1.4.RELEASE</version>
        </dependency> 
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>3.1.4.RELEASE</version>
        </dependency> 
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>3.1.4.RELEASE</version>
        </dependency>

        <!-- API de Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>PedidoVenda</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>prime-repo</id>
            <name>PrimeFaces Maven Repository</name>
            <url>http://repository.primefaces.org</url>
            <layout>default</layout>
        </repository>
    </repositories>

</project>
  • Could you post your full pom.xml? It would also help if you post your Settings.xml It is in this directory: ${user.home}/. m2/Settings.xml

  • By the way, what version of Maven are you using?

2 answers

1

Just below the comment

<!-- Abstração para envio de e-mails -->

Dependency is being defined as the following jar: simple-email:jar

In your pom.xml you also define a Repository, where Maven looks up dependencies:

<repositories>
        <repository>
            <id>prime-repo</id>
            <name>PrimeFaces Maven Repository</name>
            <url>http://repository.primefaces.org</url>
            <layout>default</layout>
        </repository>
    </repositories>

Maven is not finding this dependency in this repository. Which he’s in, I can’t help you anymore, as long as it’s a problem accessing this repository. But when I went through similar problems, I took the following approach

First, turn:

mvn dependency:resolve

In sequence, make the following checks:

  • Check if the repository you access asks for help. Maven cannot provide the correct credentials. They are placed in your ${user.home}/. m2/Settings.xml file

  • The repository you are trying to access uses SSL, and the JVM running Maven, does not trust these certificates.

  • There are problems in your network, for example, some proxy is missing to access this repository

  • Maven is unable to save the files to its local folder, for example Maven is not allowed to save.

Last but not least, check if this jar exists in this repository, if it does not exist, you need to tell Maven which folder to find this jar in.

Source: https://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

1

The artifact in question com.outjected:simple-email:jar:0.1.2-SNAPSHOT does not exist in the repository http://repository.primefaces.org (which he is trying to find), I also checked the Maven central repository and could not find it.

You must include a new repository in your application (pom.xml) or in the global settings of Maven (Settings.xml). example:

pom.xml

<repositories>
    <repository>
        <id>novo-repo</id>
        <url>http://urlnovorepo.com/repo</url>
    </repository>
</repositories>


Settings.xml

  <profile>
     <id>meuprofile</id>
     <repositories>
       <repository>
         <id>novo-repo</id>
         <name>novo repositorio global</name>
         <url>http://urlnovorepo.com/repo</url>
       </repository>
     </repositories>
   </profile>

You may notice that in the global configuration the repository was created in a new profile, you can configure it as default or activate the profile directly on the command line when running your Maven routine.

via command line Maven

mvn -Pmeuprofile ...


via configuration block setting the default profile in Settings.xml

 <activeProfiles>
   <activeProfile>meuprofile</activeProfile>
 </activeProfiles>


If Voce does not have or knows the repository one possibility is to add the dependency manually in your local repository with the command line (in the same folder where the jar in question):

mvn install:install-file -Dfile=simple-email-0.1.2-SNAPSHOT.jar \
     -DgroupId=com.outjected -DartifactId=simple-email \
     -Dversion=0.1.2-SNAPSHOT -Dpackaging=jar

From what I saw this library is a Fork from another project and you can probably find it at: https://github.com/codylerum/simple-email

Browser other questions tagged

You are not signed in. Login or sign up in order to post.