Reputation: 18123
I am facing a strange issue with Maven, looking for some help. My maven pom looks like this:
<dependency>
<groupId>org.eclipse.californium</groupId>
<artifactId>californium-core</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
And added repository like this:
<repositories>
<repository>
<id>repo.eclipse.org</id>
<name>Californium Repository</name>
<url>https://repo.eclipse.org/content/repositories/californium/</url>
</repository>
</repositories>
And Java class looks like this:
import org.eclipse.californium.core.CoapResource;
import org.eclipse.californium.core.CoapServer;
import org.eclipse.californium.core.server.resources.CoapExchange;
public class Hello extends CoapServer {
//Code here
}
Problem is Eclipse doesn't throw any error, but when I try to run maven build from eclipse, I keep on getting many compilation errors like this:
[ERROR] D:\Pradeep\Workspaces\coap\CoapServer\src\main\java\com\pradeep\coap\server\CoapServer\CoapProxyServer.java:[3,35] error: package org.eclipse.californium.core does not exist
I verified if dependencies downloaded correctly by removing dependency
tag, then even eclipse throws error, so I assume it means dependencies are downloaded correctly (I also see the jar files in Maven dependencies in eclipse). I am facing this issue while running build. Can anyone please guide me in this?
Upvotes: 1
Views: 3162
Reputation: 10115
Your Hello
class is in your source folder whereas you defined the dependency in scope test
. Either move your class to src/test/java
our change your dependency not to be a test dependency.
Eclipse cannot distinguish between the scopes and puts everything on the classpath for the whole module, regardless of the defined scope.
Upvotes: 4