Question

I have a maven project which actually builds as multiple java projects. Project B contains a class which is a child of a class sin Project A. When I try to run this class in a debugger I get a NoSuchMethod error when the method tries to call any functionality from it's parent.

The Maven setup is designed to compile every single project and place it in the maven repository so other projects can find them (it has a sense of dependency so it builds pre-req projects firsts). This is all good for deployment, but I don't want to force people debugging in eclipse to do a maven install every time the start up their debugger. Instead I tried adding pre-req projects to the class path of the applicable projects (build path -> add class folder). This doesn't work. I think it's due to having both the maven repository and the class path in my build path? but the class folders should be parsed forced and the newer class folders should be parsed before the maven install right?

How can I configure this to work without needing to re-do a maven install each time?

Was it helpful?

Solution

What exactly do your pom files look like? I often use a setup where I have one parent Maven project that is comprised of other Maven sub projects.

I will have a parent pom that looks something like this:

<?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">
<groupId>put group id here</groupId>
<artifactId>name of artifact id</artifactId>
<version>0.2.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
    <module>example-subproject-1</module>
    <module>example-subproject-2</module>
    </modules>
</project>

I'll then have pom files in the subprojects that look like this (assume this is the pom file for subproject 1):

<?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">
<parent>
    <artifactId>artifact id of parent pom</artifactId>
    <groupId>group id of parent pom</groupId>
    <version>version number of parent pom</version>
</parent>
<groupId>group id</groupId>
<artifactId>artifact id</artifactId>
<packaging>packaging</packaging>
<version>1</version>
<name>put name here</name>
<dependencies>
    <dependency>
        <groupId>group id of example subproject 2</groupId>
        <artifactId>example-subproject-2</artifactId>
        <version>version number of example subproject 2</version>
    </dependency>
</dependencies>
</project>

When I have things set up this way, I can compile the entire project if I'm in the root directory. If I just want to compile a specific directory, I just change into that directory. Make sure to include any needed subprojects in your dependencies section.

OTHER TIPS

Make sure you have the m2eclipse plugin installed.

http://eclipse.org/m2e/download/

Also, install the m2eclipse-wtp plugin

http://marketplace.eclipse.org/content/maven-integration-eclipse-wtp#.UUdUhBxwrIU

Make sure you have created your projects as 'Maven' projects. So, if you look at your 'ProjectA->Properties->Builders', you should see a 'Maven Project Builder'.

If you follow all above steps, your project dependencies should resolve correctly and you should not have errors.

If you still have errors, pls post your eclipse project structure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top