我一直在尝试使用maven构建代码.但我遇到了一个错误.这个代码可以在这个github repo上找到.谷歌播放爬虫
我的系统配置由maven显示如下:
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 19:21:28+0530)
Maven home: /Users/tushar/Downloads/apache-maven-3.0.5
Java version: 1.6.0_65, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.9", arch: "x86_64", family: "mac"
Run Code Online (Sandbox Code Playgroud)
以下是错误的Maven跟踪:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project googleplaycrawler: Compilation failure -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project googleplaycrawler: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用from_json方法构建一个文档对象.object.save()不会抛出任何错误,但文档未插入mongo.
另一方面,如果我通过为每个字段赋值来创建对象,它可以正常工作.
我无法找到原因.以下是两种情况的代码.
from flask import Flask
from flask.ext.mongoengine import MongoEngine
import json, datetime
app = Flask(__name__)
app.config["MONGODB_SETTINGS"] = {'DB': 'test','host': 'localhost'}
app.config["SECRET_KEY"] = "mySecretKey"
db = MongoEngine(app)
class User(db.Document):
user_id = db.StringField(max_length=16, primary_key = True)
username = db.StringField(min_length=8)
email = db.EmailField(required = True, unique = True)
password = db.StringField(required = True)
date_of_birth = db.DateTimeField()
gender = db.StringField(choices = ('M', 'F'))
'''
This one works. This will add a user in local mongodb(test)
'''
u1 = User()
u1.username = 'test12345' …Run Code Online (Sandbox Code Playgroud) 在查询pymongo时,我得到一个字典对象,可以直接作为对api请求的响应发送.mongoengine在查询数据库时返回Document对象的位置.因此,我必须解析每个对象,然后才能将其作为api中的响应发送.
这是我在mongoengine中查询的方式.
users = User.objects(location = 'US')
这将返回一个BaseQueryList包含User模型类型对象的对象.相反,我需要它应该返回一个用户的字典类型对象列表.