Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8323959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:53:10+00:00 2026-06-08T23:53:10+00:00

I purchased the ‘Apache Maven 3 Cookbook’ and I’m trying to learn on adding

  • 0

I purchased the ‘Apache Maven 3 Cookbook’ and I’m trying to learn on adding dependencies to my maven projects.

my main project pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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>net.srirangan.packt.maven</groupId>
<artifactId>TestModularApp</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>TestModularApp</name>
<url>http://maven.apache.org</url>
  
<properties>
 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>3.8.1</version>
  <scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.2</version>
</dependency>
</dependencies>
<modules>
<module>ChildProject</module>
<module>MyWebApp</module>
</modules>
</project>

as you can see here the packaging in this project is set to "pom" because this is the parent project.. ( that’s all i know 🙂 )

and then I created a subproject with the following pom.xml:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>net.srirangan.packt.maven</groupId>
    <artifactId>TestModularApp</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <groupId>com.xpogames.childproject</groupId>
  <artifactId>ChildProject</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>ChildProject</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    </dependency>
  </dependencies>
</project>

as you can see here i did not add a version property to the mysql-connect-java dependency because it supposed to inherit the version from the parent project. but for some reason, it doesn’t.

when I run mvn compile on that project i get an error that the dependencies.dependency.version property is missing.

any ideas what i’m doing wrong? how can I resolve the issue that i won’t need to specify versions in sub-projects too ?

thanks!

update

after watching Peter Lawrey’s answer and watching the example on the url he provided
I noticed that my main XML is missing the property <dependencyManagement> around the <dependencies>. once I added that property then I didn’t need to provide a version number in the sub-project.

Peter answer shows another method to achieve this goal.

thanks for everything!

Kfir

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T23:53:11+00:00Added an answer on June 8, 2026 at 11:53 pm

    You inherit versions from the dependencies in the dependencyManagement section of your parent pom(s) and selectively include these in child poms.

    In your case you don’t need to mention the dependency again as it already included from the parent. (As it is for JUnit)

    BTW: I use JUnit 4.10 which I haven’t found any backward compatibility problems with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently purchased a copy of Practical Android Projects . Chapter 8 talks about
I recently purchased a virtual server from Hetzner.de, and am trying to use it
I recently purchased a mac and am trying to get junit tests working on
I've just purchased Xcode 4 and am trying to develop my apps in it.
I purchased a domain: josecvega.com Whenever someone tries to access http://www.josecvega.com it forwards them
I purchased a template / theme from RocketTheme, but I can't figure out how
I purchased MicroMax A60 mobile phone which was not provided with any PC suite.
I've purchased a non-consumable product using my test user, but when I call this:
I recently purchased the domain name simply.do. I want to use it as a
I have recently purchased jQuery In Action Second Edition , and I was going

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.