您好
我正在尝试学习mongo-java driver.i遵循此mongodb文档.以下是我的代码
public class JMongoDBCDemo
{
MongoClient mongoClient;
DB db;
DBCollection coll;
public JMongoDBCDemo()
{
MongoClient mongoClient = new MongoClient( "localhost" , 27017 );
db = mongoClient.getDB( "messenger" );
coll = db.getCollection("users");
DBObject myDoc = coll.findOne();
System.out.println(myDoc);
mongoClient.close();
System.out.println("Got a collection...");
}
public static void main(String[] args){
JMongoDBCDemo mongoDemo = new JMongoDBCDemo();
}
}
Run Code Online (Sandbox Code Playgroud)
以下是输出
Apr 05, 2015 12:17:47 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
Apr 05, 2015 12:17:47 …Run Code Online (Sandbox Code Playgroud) 我正在尝试我的第一个REST应用程序.
以下是我的配置:
以下是Maven下载的罐子列表:
<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>org.prasad</groupId>
<artifactId>messenger</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>messenger</name>
<build>
<finalName>messenger</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
<exclusions>
</exclusions>
</dependency>
<!-- uncomment this to get JSON support
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency> …Run Code Online (Sandbox Code Playgroud) 有没有办法在不使用第三方库的情况下创建PDF文件,如iText,Apache PDFBox,PDFJet等?