I can’t get the artifacts into Maven

Asked

Viewed 270 times

2

I have little experience with Java programming and I’m having difficulties to include the libraries by Maven, and I don’t know if it’s really necessary to create a local Maven repository on my computer, as shown in the video below:

https://www.youtube.com/watch?v=KttjgSrh4T0

I’m following the tutorial below Algaworks:

http://www.4shared.com/zip/Bjy4Hr5y/algaworks-ebook-java-ee-7-com-.htm?locale=pt-BR

I followed the script starting from page 20 to page 29.

The Oimundoservlet.java class is showing errors in some parts of the code, I am deducing that the Servlet libraries were not included.

package com.algaworks.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class OiMundoServlet
 */
public class OiMundoServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public OiMundoServlet() {
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }

}

My pom.xml file

<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>Financeiro</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

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

    <dependencies>
        <!-- Núcleo do Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.2.6.Final</version>
            <scope>compile</scope>
        </dependency>
        <!-- Implementação de EntityManager da JPA -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.2.6.Final</version>
            <scope>compile</scope>
        </dependency>
        <!-- Driver JDBC do MySQL -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.26</version>
            <scope>compile</scope>
        </dependency>

    </dependencies>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

I know that after including the libraries I have to build in Eclipse to reference the libraries that are included in pom.xml.

Can someone help me?

is generating this error message

[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project  (/root/workspace/Financeiro/pom.xml) has 1 error
[ERROR]     Non-parseable POM /root/workspace/Financeiro/pom.xml: Duplicated tag: 'dependencies' (position: START_TAG seen ...</dependencies>\n\n\t<dependencies>... @18:16)  @ line 18, column 16 -> [Help 2]
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException
  • build Maven is running without errors? and displaying the BUILD SUCCESSFUL message at the end??

  • how do you run build Maven?

  • the simplest way is to right-click on your project, follow up to ->Run As->9 Maven Install

  • put the error message. take a look at

  • I understood now, had a duplicate of the word dependeces, our guy was worth, thank you very much.

  • was in the file Pow.xml >>> Non-parseable POM /root/Workspace/Financial/pom.xml: Duplicated tag: 'dependencies' (position: START_TAG Seen ...</dependencies> n n t<dependencies>... @18:16) @line18, column 16 -> [Help 2]

  • 1

    the file name must be pom.xml with "m". This exception is stating that the 'dependencies' tag is duplicated, so an error is occurring while reading the file.

Show 2 more comments

1 answer

2

In your pom.xml file the tag <dependencies> is appearing 2 times:

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

<dependencies>
    <!-- Núcleo do Hibernate -->
....
</dependencies>

it can only be declared 1 time, so put all dependency inside one of them and remove the other.

Browser other questions tagged

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