Spring Boot throws ClassNotFoundException with maven dependency for another project - java

I have Spring Boot project with simple EnvironmentPostProcessor implementation:
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.env.ConfigurableEnvironment;
public class DevProfilerResolverEnvironmentPostProcessor implements EnvironmentPostProcessor {
#Override
public void postProcessEnvironment(ConfigurableEnvironment configurableEnvironment, SpringApplication springApplication) {
if (configurableEnvironment.getActiveProfiles().length == 0) {
if (System.getenv().get("OS").contains("Windows")) {
configurableEnvironment.addActiveProfile("DEV");
}
}
}
}
Also, I registered this class to sprig.factories:
org.springframework.boot.env.EnvironmentPostProcessor = com.example.demo.DevProfilerResolverEnvironmentPostProcessor
Now structure looks like:
Snippet from pom file:
<?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>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
I executed with Maven:
mvn install
Now I want to use this EnvironmentPostProcessor implementation on another spring boot project. Thus I added it to dependency section for the new project:
<dependency>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
And I wrote simple service usage:
#Service
#Profile("DEV")
public class DeveloperService {
#Scheduled(cron = "1/1 * * * * ?")
public void doWork() {
System.out.println("Developers.... ");
}
}
and enabled scheduling for main class:
#SpringBootApplication
#EnableScheduling
public class LvivBootApplication {
public static void main(String[] args) {
SpringApplication.run(LvivBootApplication.class, args);
}
}
However, I got following exception after main execution:
14:56:09.822 [main] ERROR org.springframework.boot.SpringApplication - Application startup failed
java.lang.IllegalArgumentException: Unable to instantiate factory class: org.springframework.boot.env.EnvironmentPostProcessor
Caused by: java.lang.ClassNotFoundException: com.example.demo.DevProfilerResolverEnvironmentPostProcessor
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
and dependency is added to the new project:
I am running it exactly on Windows environment.
The idea is when OS is Windows add DEV profile for the first project.
Second has service which prints to console dummy info when the profile is DEV and scheduled this printing for every second.
I can't find what is missed at this example?
SOLUTION:
For making from first project library jar pom should be fixed like following:
<!--<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
</plugins>
</build>-->
Or simple to eliminate this plugin from pom file.

Your first jar is not a library jar. It's a repackaged boot jar, created by the spring boot plugin, containing the first spring boot application and all its dependencies, intended to be executed, and not to be used as a library.
If you want to use that as a library, you need to use the non-repackaged jar file, containing only the classes and resources of the project.
It's quite bizarre to have an application depend on another application, though. You should create a library project, only containing common common classes and resources, and use that as a dependency to your two spring boot applications.

I am posting because I had a similar error in similar circumstances - I searched for hours and the solution was very easy. I am using Eclipse for debugging - Eclipse doesn't use the produced jar from Maven build - it uses its own set of build paths with, as far as i understood, exploded classes etc.
My Maven project, the one that produced a JAR that I was including into my main project POM, didn't declare in any way some kind of dependency to the main project, e.g. via a common parent or whatever.
Eclipse seems to not understand that one of the dependencies I was using in the POM was a result of another local project - somehow, although the file (jar-with-dependencies) was in the Maven cache alright, it wasn't picking it up to copy to its own aforementioned set of classpath directories.
I needed to explicitly add it (my library project) into the main project via Project -> Properties -> Java Build Path -> Projects - adding it to the list titled "Required projects on the build path:"

Related

How do I include src/test/java files to run TestNG tests?

I'm just learning Java and could use your help. I'm using Eclipse, and created a Maven project using the org.openjfx archetype. Everything seems to work fine except when I try to write tests in src/test/java, which causes an error.
An error occurred while instantiating class
starcraft.warcraft.test.TestClass: Unable to make public
starcraft.warcraft.test.TestClass() accessible: module
starcraft.warcraft does not "exports starcraft.warcraft.test" to
module org.testng
This is how I created the project with default settings in Eclipse:
Project Setup with Maven Archetype Selection
Now, when Eclipse creates the project, it doesn't have a src/test/java folder, so I create that manually. Then I create a class called "TestClass" inside a package "starcraft.warcraft.test" inside src/test/java, and I add a simple method to test inside the App class called "adder". You can see the project structure
Project Structure
package starcraft.warcraft;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class App extends Application {
#Override
public void start(Stage stage) {
var javaVersion = SystemInfo.javaVersion();
var javafxVersion = SystemInfo.javafxVersion();
var label = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
var scene = new Scene(new StackPane(label), 640, 480);
stage.setScene(scene);
stage.show();
}
// WILL TEST THIS METHOD
public static int adder(int digit1, int digit2) {
return digit1 + digit2;
}
public static void main(String[] args) {
launch();
}
}
Now I want to use TestNG for the tests, and so I include it in my POM which is
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>starcraft</groupId>
<artifactId>warcraft</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.6</version>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>starcraft.warcraft.App</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
This is the default POM created by the Maven archetype except for the TestNG dependency I added. When I try to use TestNG, Eclipse makes me add it to the module path like so:
Maven saying I need to add the TestNG library
And here is my module-info:
module starcraft.warcraft {
requires javafx.controls;
requires org.testng;
exports starcraft.warcraft;
}
OK, all good so far, but now when I try to run my test inside TestClass:
package starcraft.warcraft.test;
import org.testng.annotations.Test;
import starcraft.warcraft.App;
public class TestClass {
#Test
public void testAdder() {
int sum = App.adder(1, 2);
System.out.println(sum);
}
}
I get the error, which again is
An error occurred while instantiating class
starcraft.warcraft.test.TestClass: Unable to make public
starcraft.warcraft.test.TestClass() accessible: module
starcraft.warcraft does not "exports starcraft.warcraft.test" to
module org.testng
I can't figure out how to do the export. When I try making the entry in module-info, it doesn't give me the option of adding the package in src/test/java, the only packages it allows me to choose from are in src/main/java.
I don't understand modules well. How can I get the program to let me run tests from src/test/java?
Thanks everyone who looked at this. I solved it by following these steps:
Delete module-info.java. This turns it into a nonmodular project which is fine for me. I hesitated to do this because the Maven JavaFX archetype included it, but as it says here somewhere
https://openjfx.io/openjfx-docs/#IDE-Eclipse
you can just delete it after its created.
The problem then if you try to run the project is it will give you a warning that JavaFX isn't included as a module. It will still run, but its best to get rid of this incase of problems down the road. So you need to download the JavaFX libraries, place them in your hard drive, and then include them in your project via VM arguments in Eclipse:
right click project -> Run configuration -> Arguments tab -> add in the VM arguments area something like:
--module-path [fully qualified path to lib folder containing downloaded JavaFX] --add-modules javafx.controls
path would be like "C:\javafx\lib" or wherever you placed the downloaded JavaFX.
Then it should run, and project will still build using Maven, but I'm not sure if its using the JavaFX which is still in the Maven POM or the one I specified on the C drive. But it works. Any help on whats happening there would be appreciated. Thanks

My JUnit tests don't work when I execute them via maven

I use Maven on my test project and I wanted to test test option in Maven's lifecycle, but my JUnit test failed. I have a class named Arithmetics in src.main.java package and a class named ArithmeticsTest in src.test.java package.
When I run ArithmeticsTest on my own using IntelliJ IDEA everything works OK, and I have expected java.lang.AssertionError, so why I don't have such when I run test option in maven?
Console output:
T E S T S
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
src.main.java.Arithmetics.java
public class Arithmetics
{
public static int add(int a, int b)
{
return a + b;
}
}
src.test.java.ArithmeticsTest.java
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class ArithmeticsTest
{
#Test
public void testAdd()
{
assertEquals(4, Arithmetics.add(2, 3));
}
}
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>groupId</groupId>
<artifactId>Test</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
There are three wrong things I can spot based on your question, while they might not provide a complete answer I hope they'll will be a step in a right direction:
src/main/java and src/test/java is not a package as you write. Its a folder layout supported by maven, basically , if you have a code in com.myorg.somepackage.Arithmetics
Make sure you have the following layout at the level of actual physical folders:
src
main
java
com
myorg
somepackage
Arithmetics.java
test
java
com
myorg
somepackage
ArithmeticsTest.java
For both java files the package must be com.myorg.somepackage:
package com.myorg.somepackage;
public class Arithmetics {}
And
package com.myorg.somepackage;
public class ArithmeticsTest {}
I know it might be a wrong naming that you've used in the question, but still I have to state it because it might cause an actual issue
The second issue is that for some reason you seem to configure your surefire plugin to use test ng which is an alternative to junit. It can happen because testng is placed as a dependency - I can only speculate because you don't really show the full surefire plugin configure and do not provide a full list of dependencies, but you've got and idea I believe :)
This is wrong because you use the junit5 dependencies as well as the imports that correspond to the junit 5.
The dependencies on the junit 5 are completely messy:
You seem to have two dependencies on just the same with the different scope, its really a wrong thing to do. Make sure you use only the test scope and have all the relevant dependencies. Read here for instruction of how to configure the surefire plugin
In addition, for the sake of completeness of the answer, check that you use the recent version of surefire plugin, if its too old the chances are that it won't be able to run jupiter engine (junit 5)
As other answer already pointed out few things which may go wrong in your case, I am just adding the solution to your pom xml.
The surefire plugin version is the main culprit. Default with maven (2.12.4) will not work with junit-5 jupiter engine.
So just add the plugin in your with version 2.22.1 in your pom, it should work after that, assuming your folder structure as per required (see other answer).
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>

Bootstrap a simple Java SE "Hello World" desktop application using JBoss Weld environment causes a runtime error

I'd like to use JBoss Weld as a CDI facility in a classic Hello World application in a maven structured project. To keep the things as clean & simple as possible, I only created a Weld environment object and nothing more. I also created the deployment descriptor file beans.xml in src/main/resources/META-INF and src/test/resources directories. I did't go further by creating and initializing a WeldContainer etc. I'm just wondering why this settings don't work in the first place.
The application compiles perfectly and generates an executable jar file with mvn package command. However I got a runtime error:
C:\dev\eclipse-workspace\my-app>java -cp target/my-app-1.0.jar app.Hello
Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/weld/environment/se/Weld
at app.Hello.main(Hello.java:7)
Caused by: java.lang.ClassNotFoundException: org.jboss.weld.environment.se.Weld
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.j
ava:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoader
s.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 1 more
So, here is my main class:
1 package app;
2
3 import org.jboss.weld.environment.se.Weld;
4
5 public class Hello {
6 public static void main(String[] args) {
7 Weld weld = new Weld();
8
9 System.out.println("Hello World");
10
11 weld.shutdown();
12 System.exit(0);
13 }
14 }
my pom.xml file:
<?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
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>jee</groupId>
<artifactId>my-app</artifactId>
<version>1.0</version>
<name>my-app</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>13</maven.compiler.source>
<maven.compiler.target>13</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>3.1.3.Final</version>
</dependency>
</dependencies>
</project>
and lastly my project structure:
Your help is appreciated in advance.
Thank you.
Alex
You will note that java -cp target/my-app-1.0.jar app.Hello does not include the Weld jars on the classpath (unless your jar file's META-INF/MANIFEST.MF has a Class-Path entry that references them). That is why Weld classes cannot be found at runtime when you start your application in this manner.

Spring Boot Error: java.lang.NoClassDefFoundError: org/springframework/util/Assert

I am new to Spring Boot and following some video tutorials to get started. I created a Maven project, added a parent dependency of artifact id spring-boot-starter-parent, added dependency for spring-boot-starter-web and spring-boot-starter-test. This is the Application.java:
#RestController
#EnableAutoConfiguration
public class Application {
#RequestMapping("/")
public String home() {
return "Hello World";
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Note:
src/test/java and src/test/resources packages are empty. This is a Maven Project, I am using STS, performed "Maven -> Update Project..." and cleaned/build the entire project multiple times using STS IDE and I am getting the following error. Also, I tried to create a new project in STS and still I am getting the following error:
I am getting this error when I run this as a Spring Boot App:
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/util/Assert
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:263)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:247)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
at com.boot.Application.main(Application.java:18)
Caused by: java.lang.ClassNotFoundException: org.springframework.util.Assert
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 5 more
Please help me in resolving this issue.
EDIT:
This is my 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.deloitte.boot</groupId>
<artifactId>boot-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>boot-test</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
This is my project directory stricture:
I have fixed that issue like this, first I removed my folder .m2 and then I run mvn clean install into my directory spring boot project. that's all!
It is better to follow software principles while you are learning and making projects. Try to make project in a way that separation of concern is always achieved, that will make your code not just easy to understand, but to debug and fix too.
Change your application class like this:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Now make another package controller and make class in it for your testing
#RestController
//You can add this if you want or remove this class level mapping
#RequestMapping("/testApp")
public class TestController {
#RequestMapping("/")
public String home() {
return "Hello World";
}
}
For further help. please check this (official spring.io tutorial) simple example of Spring Boot App in STS.
And another one is this very simple and straightforward to get Spring Boot App up and running.
Edit: please add starter test in pom.xml as well.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>1.5.10.RELEASE</version>
<scope>test</scope>
</dependency>
Had the same issue with IntelliJ and a brand new project created from Spring Initializer. Saw this message when trying to compile manually:
[ERROR] error reading /Users/mike/.m2/repository/org/springframework/spring-core/5.1.4.RELEASE/spring-core-5.1.4.RELEASE.jar; zip file is empty
Turns out the files downloaded from maven central were corrupt:
ls -al /Users/mike/.m2/repository/org/springframework/spring-core/5.1.4.RELEASE/spring-core-5.1.4.RELEASE.jar
-rw-r--r-- 1 mike staff 0 Jan 16 20:55
/Users/mike/.m2/repository/org/springframework/spring-core/5.1.4.RELEASE/spring-core-5.1.4.RELEASE.jar
Removing the entire directory and rebuilding forced it to download a new copy of of the missing library:
./mvnw compile
Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/spring-core/5.1.4.RELEASE/spring-core-5.1.4.RELEASE.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/springframework/spring-core/5.1.4.RELEASE/spring-core-5.1.4.RELEASE.pom (3.6 kB at 7.6 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/spring-core/5.1.4.RELEASE/spring-core-5.1.4.RELEASE.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/springframework/spring-core/5.1.4.RELEASE/spring-core-5.1.4.RELEASE.jar (1.3 MB at 3.6 MB/s)
Had the same issue, after I installed STS (before that, everything in Eclipse was going ok).
I removed the springframework folder that was inside the .m2 folder, then ran 'mvn clean install' in my project directory. After that I encountered an issue with my assertj-core-3.11.1.jar and mockito-core-2.23.0.jar (ZipFile invalid LOC header (bad signature)), so I also removed them and ran "mvn spring-boot:run".
Now it works (but I can't really explain why).

Eclipse NoSuchMethod exception; configuring build path

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?
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.
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.

Categories

Resources