How Do You Troubleshoot the Maven Error “Malformed POM…Unrecognised tag: ‘dependency'”?

Problem scenario
You run a Maven (mvn) command. But you receive an error like this:

[INFO] Scanning for projects…
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Malformed POM /home/jdoe/b/gs-maven/initial/src/pom.xml: Unrecognised tag: 'dependency' (position: START_TAG seen …\n \n \n … @17:17) @ /home/jdoe/b/gs-maven/initial/src/pom.xml, line 17, column 17
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project org.springframework:gs-maven:0.1.0 (/home/jdoe/b/gs-maven/initial/src/pom.xml) has 1 error
[ERROR] Malformed POM /home/jdoe/b/gs-maven/initial/src/pom.xml: Unrecognised tag: 'dependency' (position: START_TAG seen …\n \n \n … @17:17) @ /home/jdoe/b/gs-maven/initial/src/pom.xml, line 17, column 17 -> [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

What do you do to fix it?

Solution

Inside your pom.xml file encapsulate the <dependency> and </dependency> within tags <dependencies> and </dependencies> respectively.  So instead of this:
<dependency>
  ...
</dependency>

have it look like this:

<dependencies>
  <dependency>
    ...
  <dependency>
</dependencies>

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *