Create MongoDB document with non-string values in Java -
i can't life of me create mongodb document in java values aren't strings. i've tried using "put" , "append" method, both homecoming error similar 1 below.
basicdbobject doc = new basicdbobject(); doc.put("foo", "bar"); // works doc.put("ugh", 5); // doesn't doc.put("plz", 7l); // nor // [error] failed execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project league: compilation failure // [error] /home/calvin/league/src/main/java/gg/bram/league/app.java:[60,19] error: no suitable method found put(string,int) // relevant bit: "error: no suitable method found put(string,int)"
output of java -version
:
java version "1.7.0_65" openjdk runtime environment (icedtea 2.5.1) (7u65-2.5.1-5~deb7u1) openjdk 64-bit server vm (build 24.65-b04, mixed mode)
using mongo-java-driver 2.12.4, proof in pom.xml file:
<dependency> <groupid>org.mongodb</groupid> <artifactid>mongo-java-driver</artifactid> <version>2.12.4</version> </dependency>
this killing me, i'm doing nil different tutorials/docs can find online, please help!!
thanks
edit: entire 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/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelversion> <groupid>gg.bram.league</groupid> <artifactid>league</artifactid> <packaging>jar</packaging> <version>1.0-snapshot</version> <name>league</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupid>org.json</groupid> <artifactid>json</artifactid> <version>20140107</version> </dependency> <dependency> <groupid>org.apache.httpcomponents</groupid> <artifactid>httpclient</artifactid> <version>4.3.6</version> </dependency> <dependency> <groupid>org.mongodb</groupid> <artifactid>mongo-java-driver</artifactid> <version>2.12.4</version> </dependency> </dependencies> <build> <pluginmanagement> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-jar-plugin</artifactid> <version>2.5</version> </plugin> </plugins> </pluginmanagement> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-jar-plugin</artifactid> <version>2.5</version> <configuration> <source>1.7</source> <target>1.7</target> <archive> <manifest> <addclasspath>true</addclasspath> <mainclass>gg.bram.league.app</mainclass> <classpathmavenrepositorylayout>true</classpathmavenrepositorylayout> <classpathprefix>/home/calvin/.m2/repository/</classpathprefix> </manifest> </archive> </configuration> </plugin> </plugins> </build> </project>
you have source , target set in wrong place; should on maven-compiler-plugin
.
java mongodb
No comments:
Post a Comment