Reputation: 20045
(warning: am a complete Java-newbie!)
At this point I simply want to import com.mongodb.*. But this fails and I can't see why. I am using Intellij CE and Maven for the built.
The Java code:
package com.tengen;
import com.mongodb.*;
/**
* Created by raffael on 04.06.14.
*/
public class HelloWorldMongoDBStyle {
public static void main(String[] args) {
}
}
(If I comment the importing of com.mongodb.* then the make process / compilation works fine - "compilation completed successfully")
The error message:
/home/raffael/M101J/src/main/java/com/tengen/HelloWorldMongoDBStyle.java
Error:(3, 1) java: package com.mongodb does not exist
The relevant part of the POM:
<dependencies>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.11.4</version>
<scope>test</scope>
</dependency>
</dependencies>
The odd thing is that Intellij successfully downloads and integrates the module:
I can also confirm that the jar is located where the library settings assume it to be and that it contains a folder com/mongodb/ with a lot of class-files.
Any idea what the issue might be or how to figure it out?
Upvotes: 1
Views: 1296
Reputation: 109557
It is probably a copy error: You got a test scope.
<scope>test</scope>
This means that only in test packages (src/main/test
) an import is allowed. For unit tests.
Removing the line will give the entire scope.
Upvotes: 1