小编laf*_*ste的帖子

如何增加Docker-machine内存Mac

我是Docker的新手,并试图通过本教程从Docker镜像设置MemSQL - http://docs.memsql.com/4.0/setup/docker/.我在Mac上,教程使用boot2docker似乎已被弃用.

VM需要4GB内存才能运行.本教程指定了如何执行此操作,boot2docker但我找不到使用docker-machine/docker工具箱执行此操作的方法.

这是我正在使用的命令和错误我只是试图通过教程而不改变boot2docker配置.

docker run --rm --net=host memsql/quickstart check-system
Error: MemSQL requires at least 4 GB of memory to run.
Run Code Online (Sandbox Code Playgroud)

macos virtualbox singlestore docker docker-machine

99
推荐指数
6
解决办法
7万
查看次数

如何区分Spring Rest Controller中部分更新的null值和未提供值

我试图在Spring Rest Controller中使用PUT请求方法部分更新实体时,区分空值和未提供的值.

以下面的实体为例:

@Entity
private class Person {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /* let's assume the following attributes may be null */
    private String firstName;
    private String lastName;

    /* getters and setters ... */
}
Run Code Online (Sandbox Code Playgroud)

我的人员库(Spring Data):

@Repository
public interface PersonRepository extends CrudRepository<Person, Long> {
}
Run Code Online (Sandbox Code Playgroud)

我使用的DTO:

private class PersonDTO {
    private String firstName;
    private String lastName;

    /* getters and setters ... */
}
Run Code Online (Sandbox Code Playgroud)

我的Spring RestController:

@RestController
@RequestMapping("/api/people")
public class PersonController {

    @Autowired
    private PersonRepository people; …
Run Code Online (Sandbox Code Playgroud)

java rest json spring-mvc jackson

27
推荐指数
4
解决办法
5211
查看次数

Celery - 没有名为 5 的模块

将 celery 和 django-celery 更新到 3.1 后:

$ pip freeze | grep celery
celery==3.1.18
django-celery==3.1.16
Run Code Online (Sandbox Code Playgroud)

启动服务器时遇到此错误:

Traceback (most recent call last):
  File "app/manage.py", line 16, in <module>
    execute_from_command_line(sys.argv)
  [...]
  File "/Users/xxx/.virtualenvs/yyy/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/Users/xxx/.virtualenvs/yyy/lib/python2.7/site-packages/django/conf/__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'settings' (Is it on sys.path?): No module named five
Run Code Online (Sandbox Code Playgroud)

使用:

  • Django 1.4.21
  • 蟒蛇 2.7

python django celery python-2.7 django-celery

16
推荐指数
1
解决办法
2万
查看次数

为什么在创建表后删除django DATABASE_OPTIONS的"init_command set engine = INNODB"?

有关创建数据库表的文档说:

另一个选择是在创建表之前使用MySQLdb的init_command选项:

DATABASE_OPTIONS = {
   "init_command": "SET storage_engine=INNODB",
}
Run Code Online (Sandbox Code Playgroud)

这会在连接到数据库时设置默认存储引擎.创建表后,应删除此选项,因为它只在表创建期间向每个数据库连接添加一个查询.

有谁知道为什么有必要在创建表后删除此选项?

mysql django innodb

11
推荐指数
2
解决办法
6038
查看次数

Django调试工具栏不显示SQL

我最近安装了django-debug-toolbar.工具栏工作,我可以看到侧面的标签.但是,即使我明显执行了SQL查询(例如在管理员中),SQL选项卡中也没有显示任何内容: 在此输入图像描述

我的设置如下:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2'
        'NAME': 'mydatabase'
         ....
    }
}

# Backwards compatability with apps
DATABASE_ENGINE = DATABASES['default']['ENGINE'].split('.')[-1]
DATABASE_NAME = DATABASES['default']['NAME']

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
)

INSTALLED_APPS = (
    ...
    'debug_toolbar',
    ...
)

# Settings for the django-debug-toolbar
DEBUG_TOOLBAR_PANELS = (
    'debug_toolbar.panels.version.VersionDebugPanel',
    'debug_toolbar.panels.cache.CacheDebugPanel',
    'debug_toolbar.panels.timer.TimerDebugPanel',
    'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
    'debug_toolbar.panels.headers.HeaderDebugPanel',
    'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
    'debug_toolbar.panels.template.TemplateDebugPanel',
    'debug_toolbar.panels.sql.SQLDebugPanel',
    'debug_toolbar.panels.signals.SignalDebugPanel',
    # 'debug_toolbar.panels.logger.LoggingPanel',
)

def custom_show_toolbar(request):
    return request.user.is_staff

DEBUG_TOOLBAR_CONFIG = {
    'INTERCEPT_REDIRECTS':False,
    'SHOW_TOOLBAR_CALLBACK':custom_show_toolbar,
    'SHOW_TEMPLATE_CONTEXT':True,
    'HIDE_DJANGO_SQL':False,
}
Run Code Online (Sandbox Code Playgroud)

我正在使用Django 1.3和工具栏版本0.8.5.对这个问题的任何帮助都会很棒......

编辑: 根据答案,我决定发布我如何处理我的视图功能:

def func1(query, …
Run Code Online (Sandbox Code Playgroud)

django django-debug-toolbar django-1.3

9
推荐指数
2
解决办法
3851
查看次数

maven依赖树 - 版本管理

在我的项目中,我看到以下内容

[INFO] |  |  \- xalan:xalan:jar:2.7.2:compile (version managed from 2.7.0)
[INFO] |  |     \- xalan:serializer:jar:2.7.2:compile
Run Code Online (Sandbox Code Playgroud)

这个(版本管理)是否意味着Xalan 2.7.2覆盖2.7.0?

注意: - 在我的父pom中,我在dependencyManagement下有2.7.2.所以我假设上述方法Xalan 2.7.0被2.7.2覆盖但是请确认一下?

谢谢

pom.xml maven

7
推荐指数
1
解决办法
5251
查看次数

hibernate缓存和Spring框架缓存有什么区别?

我有一个应用程序,我从数据库中获取数据(使用hibernate).我想每天一次加载具有数据库状态的缓存(每个用户)并使用缓存.

我正在使用Spring框架和Hibernate,我知道它们都有一些缓存的可能性.

它们之间有什么区别?什么是更好的选择?

java spring caching hibernate spring-mvc

6
推荐指数
2
解决办法
3026
查看次数

Spring MVC 3:在不同的控制器中使用相同的@RequestMapping,使用集中的XML URL映射(混合xml /注释方法)

我喜欢将所有映射保存在同一个地方,所以我使用XML配置:

<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">

    <property name="mappings">
        <value>
            /video/**=videoControllerr
            /blog/**=blogController
        </value>
    </property>
    <property name="alwaysUseFullPath">
        <value>true</value>
    </property>
</bean>
Run Code Online (Sandbox Code Playgroud)

如果我在不同的控制器中创建具有相同名称的第二个请求映射,

@Controller
public class BlogController {
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    public String info(@RequestParam("t") String type) {
        // Stuff
    }
}

@Controller
public class VideoController {
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    public String info() {
        // Stuff
    }
}
Run Code Online (Sandbox Code Playgroud)

我得到一个例外:

Caused by: java.lang.IllegalStateException: Cannot map handler 'videoController' to URL path [/info]: There is already handler of type [class com.cyc.cycbiz.controller.BlogController] mapped.
Run Code Online (Sandbox Code Playgroud)

有没有办法在不同的控制器中使用相同的请求映射?

我想要2个网址:

/video/info.html …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc request-mapping

4
推荐指数
1
解决办法
9404
查看次数

使用 Collections.sort(arrayListName) 按 id 对充满对象的 ArrayList 进行排序

我有一个库存类,它创建一个充满对象 Item 的 ArrayList,它也是一个类。我知道我必须调用 Collections.sort(items);才能对 ArrayList 进行排序(顺便说一下,它称为项目)。作业说我必须在 Item 类上使用一个接口,我不知道是否要实现 Comparator 或 Comparable,然后为方法compareTo()compare()方法编写什么。另外,我Collections.sort(items)在声明 ArrayList 后立即接到电话,这样可以吗?

Comparable<Item>编辑:我的老师刚刚澄清说她希望我们在 Item 类上实现。

java sorting arraylist comparable comparator

4
推荐指数
1
解决办法
1万
查看次数

使用pip安装任何模块时出错,但easy_install有效

每当我尝试使用pip安装任何模块时,我都会收到此错误,但easy_install工作正常.我的Ubuntu 12.04机器中没有配置代理.以前它工作正常,只是知道,它是如何突然停止工作的.

这是我得到的错误,在运行时sudo pip install <any_package_name>:

Exception:
Traceback (most recent call last):
  File "/tmp/tmpOA61D3/pip.zip/pip/basecommand.py", line 246, in main
    status = self.run(options, args)
  File "/tmp/tmpOA61D3/pip.zip/pip/commands/install.py", line 342, in run
    requirement_set.prepare_files(finder)
  File "/tmp/tmpOA61D3/pip.zip/pip/req/req_set.py", line 345, in prepare_files
    functools.partial(self._prepare_file, finder))
  File "/tmp/tmpOA61D3/pip.zip/pip/req/req_set.py", line 290, in _walk_req_to_install
    more_reqs = handler(req_to_install)
  File "/tmp/tmpOA61D3/pip.zip/pip/req/req_set.py", line 415, in _prepare_file
    req_to_install, finder)
  File "/tmp/tmpOA61D3/pip.zip/pip/req/req_set.py", line 376, in _check_skip_installed
    finder.find_requirement(req_to_install, self.upgrade)
  File "/tmp/tmpOA61D3/pip.zip/pip/index.py", line 425, in find_requirement
    all_versions = self._find_all_versions(req.name)
  File "/tmp/tmpOA61D3/pip.zip/pip/index.py", line 349, in _find_all_versions
    index_locations …
Run Code Online (Sandbox Code Playgroud)

python sockets pyopenssl

3
推荐指数
1
解决办法
1997
查看次数