小编Mar*_*erg的帖子

scp给出"不是常规文件"

我在Linux上使用scp时遇到问题,它说"不是常规文件".我看了其他问题/答案,但我找不到有什么问题......我写道:

scp aa@aa:/home/pictures/file.fits .
Run Code Online (Sandbox Code Playgroud)

复制file.fitsaa@aa,/home/pictures到当前目录.我也尝试过不使用/home/,但它既不起作用......

你明白什么是错的吗?

linux scp

27
推荐指数
5
解决办法
7万
查看次数

用mongodb java驱动程序查找后如何调用count操作

我正在使用MongoDB 3.0.假设有一组文件命名photos,其结构是

{"_id" : 1, photographer: "jack"}
Run Code Online (Sandbox Code Playgroud)

使用database.getCollection("photos"),Mongodb将返回一个MongoCollection对象,我有方法count()获取返回的数字文件.

但是,当我使用特定条件进行查询时.例如,查找ID小于100的文档:

photosCollections.find(Document.parse("{_id : {$lt : 100}}"))
Run Code Online (Sandbox Code Playgroud)

上面的find方法将始终返回一个不提供count()功能的游标.那么我怎么知道返回了多少文件呢?我知道在命令行上,我可以使用

db.photos.find({_id : {$lt : 100}}).count()
Run Code Online (Sandbox Code Playgroud)

当然,我可以通过迭代器并自己计算文档数量.但是我发现它真的很笨拙.我想知道MongoDB java驱动程序是否提供了这样的功能来计算find()方法返回的文件数量?如果没有,决定背后的原因是什么?

mongodb mongodb-java

15
推荐指数
5
解决办法
2万
查看次数

错误-25204在iOS应用程序UI测试期间获取元素快照的原因

我在UI测试期间遇到以下错误(使用iPhone 6的模拟器):

Assertion Failure: UI Testing Failure - Failure getting snapshot Error
Domain=XCTestManagerErrorDomain Code=9 "Error -25204 getting snapshot
for element <AXUIElement 0x7fbd6be217d0> {pid=6874}"
UserInfo={NSLocalizedDescription=Error -25204 getting snapshot for
element <AXUIElement 0x7fbd6be217d0> {pid=6874}}

<unknown>:0: error: -[*screen name*] : UI Testing Failure - Failure
getting snapshot Error Domain=XCTestManagerErrorDomain Code=9 "Error
-25204 getting snapshot for element <AXUIElement 0x7fbd6be217d0> {pid=6874}" UserInfo={NSLocalizedDescription=Error -25204 getting
snapshot for element <AXUIElement 0x7fbd6be217d0> {pid=6874}}
Run Code Online (Sandbox Code Playgroud)

场景类似于UI测试正常工作的其他场景.所以,我不确定为什么在某些元素上获取快照时出错.

我使用辅助功能检查器进行了检查,所有元素似乎都有一个标识符.

这与Xcode版本7.3(7D175).

testing user-interface snapshot ios

14
推荐指数
0
解决办法
654
查看次数

如何使用SpEL处理Thymeleaf中的本地化消息

我是ThymeLeaf的初学者,并且除了@PreAuthorize注释之外没有太多使用SpEL ,所以请非常友好地帮助我.

我正在使用ThymeLeaf(版本2.1.2)和Spring(4.0.2.RELEASE),thymeleaf-spring4并且(据我所知)它用SpEL替换了默认的OGNL脚本.

我想要实现的只是本地化的字符串通过#strings.capitalize函数大写.这是我到目前为止尝试的内容:

<h1 th:text="#{retrievable.key}">Text to be replaced</h1>
Run Code Online (Sandbox Code Playgroud)

完美地工作并给出预期的结果.

现在,当我尝试这个:

<h1 th:text="${#strings.capitalize(#{retrievable.key})}">Text to be replaced</h1>
Run Code Online (Sandbox Code Playgroud)

我得到以下异常(根本原因,为清楚起见省略了):

org.springframework.expression.spel.SpelParseException:
EL1043E:(pos 21): Unexpected token.  Expected 'identifier' but was 'lcurly({)'
Run Code Online (Sandbox Code Playgroud)

好的.只是为了好玩,我省略了大括号并获得了我所期望的:它<h1>是空的.

所以现在我认为可能需要对消息的检索进行预处理,retrievable.key以便在评估时 #strings.capitalize对其进行评估.虽然这对我来说似乎违反直觉和不合逻辑,因为这会破坏所有编程规则,我尝试了这种方法.它也不起作用:使用

${#strings.capitalize(__#retrievable.key__)}
Run Code Online (Sandbox Code Playgroud)

导致

org.thymeleaf.exceptions.TemplateProcessingException:
Could not parse as expression: "#retrievable.key"
Run Code Online (Sandbox Code Playgroud)

和使用

${#strings.capitalize(__#{retrievable.key}__)}
Run Code Online (Sandbox Code Playgroud)

导致(你猜对了)<h1></h1>.

我知道实际问题可以通过CSS或JavaScript解决,但它不一定是关于大写或大写,而是处理本地化字符串,这是一个例子.

那我在这里错过了什么?

Thymeleaf论坛提供的解决方案

ThymeLeaf论坛的Zemi提供了以下优雅的解决方案:

<h1 th:text="${#strings.capitalize('__#{retrievable.key}__')}">Text to be replaced</h1>
Run Code Online (Sandbox Code Playgroud)

请注意单引号.预处理似乎真的意味着在Thymeleaf中进行预处理.

不过,我接受了第一个工作答案.

java spring localization spring-el thymeleaf

11
推荐指数
1
解决办法
4297
查看次数

使用Jersey的ExceptionMapper映射Shiro的AuthenticationException

前言

首先,我最诚挚地为这个问题道歉,但我真的不知道如何缩短它,因为每个部分都是一个特例.不可否认,我可能会对此视而不见,因为我现在正撞在墙上几天,我开始变得绝望.

我非常尊重和感谢所有读过它的人.

目的

我想能够映射四郎的的AuthenticationException和它的子类JAX-RS响应利用泽西ExceptionMappers,建立使用吉斯3.0喷油器它创建一个嵌入式码头.

环境

  • Guice 3.0
  • Jetty 9.2.12.v20150709
  • 泽西岛1.19.1
  • Shiro 1.2.4

设置

嵌入式Jetty使用Guice Injector创建

// imports omitted for brevity
public class Bootstrap {

    public static void main(String[] args) throws Exception {

      /*
       * The ShiroWebModule is passed as a class
       * since it needs a ServletContext to be initialized
       */
        Injector injector = Guice.createInjector(new ServerModule(MyShiroWebModule.class));

        Server server = injector.getInstance(Server.class);

        server.start();
        server.join();
    }
}
Run Code Online (Sandbox Code Playgroud)

ServerModule结合了Jetty服务器提供者:

public class ServerModule extends …
Run Code Online (Sandbox Code Playgroud)

jersey guice embedded-jetty shiro

11
推荐指数
1
解决办法
894
查看次数

loginButton.registerCallback无法解析方法

错误:(36,20)错误:找不到符号方法registerCallback(CallbackManager,>)

当我从我的Mainactivity调用这个registerCallback时facebook sdk 4.0's lib.这是我的课

  public class MainActivity extends Activity {
        TextView tv;
        Button loginButton;
        CallbackManager callbackManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.e("Oncreate", "Now on On create");
        FacebookSdk.sdkInitialize(getApplicationContext());
        callbackManager = CallbackManager.Factory.create();
        tv =(TextView)findViewById(R.id.tv);

        loginButton = (LoginButton)findViewById(R.id.login_button);
        loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                // App code
            }

            @Override
            public void onCancel() {
                // App code
            }

            @Override
            public void onError(FacebookException exception) {
                // App code
            }
        });

        LoginManager.getInstance().registerCallback(callbackManager,
                new FacebookCallback<LoginResult>() {
                    @Override …
Run Code Online (Sandbox Code Playgroud)

android facebook callback

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

继承和TypeScript出错:X不是构造函数类型

我正在使用一个小型webapp并使用typescript,node.js,express和mongodb.

我有这个超级类,我想要继承其他两个类.课程如下.当我编译时,试图继承的两个类抱怨超类(给出相同的错误):"[类文件路径(在本例中为A)]不是构造函数类型"

A.ts

export class A
{
    //private fields...

    constructor(username: string, password: string, firstName: string,
        lastName: string, accountType: string) 
    {
        // initialisation
    }
}
Run Code Online (Sandbox Code Playgroud)

B.ts

import A = require('./A);
export class B extends A
{
    constructor(username: string, password: string, firstName: string,
        lastName: string, accountType: string) 
    {
        super(username, password, firstName, lastName, accountType);
    }
}
Run Code Online (Sandbox Code Playgroud)

C.ts

import A = require('./A );
export class C extends A
{
    constructor(username: string, password: string, firstName: string,
        lastName: string, accountType: string) 
    {
        super(username, password, firstName, lastName, …
Run Code Online (Sandbox Code Playgroud)

javascript inheritance typescript

9
推荐指数
1
解决办法
7786
查看次数

什么是 Windows 10 中的受管端口排除?

我在 Windows 10 中启用了 hyper-v。当我检查排除的端口时,我得到:

C:\> netsh interface ipv4 show excludedportrange protocol=tcp

Protocol tcp Port Exclusion Ranges

Start Port    End Port
----------    --------
      5357        5357
      9800        9800
      9801        9801
     49671       49770
     49871       49970
     50000       50059     *
     61117       61216
     61220       61319
     61902       62001

* - Administered port exclusions.
Run Code Online (Sandbox Code Playgroud)

为什么 Hyper-V 保留这些端口?

受管端口排除(即范围 50000-50059 )与其他端口排除有何不同?

例如,当我尝试在 golang 中使用 net.Listen() ping 所有这些端口时,除 50000-50059 之外的所有端口都返回错误:

listen tcp 127.0.0.1:9801: bind: An attempt was made to access a socket in a way forbidden by its access …
Run Code Online (Sandbox Code Playgroud)

hyper-v windows-10 docker-for-windows

8
推荐指数
1
解决办法
4385
查看次数

H2:如何设置默认架构和数据库?

我正在使用Liquibase我的数据库更新并对其进行测试H2.

Spring用来配置属性.我用

dataSource.setUrl("jdbc:h2:mem:test_common");
Run Code Online (Sandbox Code Playgroud)

连接到test_common数据库,但它没有成功.

我意识到H2 database != Schema,因此我尝试将默认架构设置test_common

dataSource.setUrl("jdbc:h2:mem:test_common;INIT=CREATE SCHEMA test_common\\; SET SCHEMA test_common");
Run Code Online (Sandbox Code Playgroud)

但这没有用,我把日志视为

INFO 5/26/14 2:24 PM:liquibase: Dropping Database Objects in schema: TEST_COMMON.PUBLIC
INFO 5/26/14 2:24 PM:liquibase: Creating database history table with name: PUBLIC.DATABASECHANGELOG
INFO 5/26/14 2:24 PM:liquibase: Creating database history table with name: PUBLIC.DATABASECHANGELOG
INFO 5/26/14 2:24 PM:liquibase: Successfully released change log lock
INFO 5/26/14 2:24 PM:liquibase: Successfully acquired change log lock
INFO 5/26/14 2:24 …
Run Code Online (Sandbox Code Playgroud)

database spring h2 liquibase

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

sapui5中的本地化(i18n)没有出现fragment.xml文件

我有一个按钮(创建应用程序),如果我点击一个按钮,将出现一个碎片对话框.这里能够显示碎片化的对话框.但内部化(i18n)没有出现在字段中.(对于xml能够显示i18nfragment.xml文件无法显示的文件i18n/)

component.js:

createContent : function() {

        // create root view
        var oView = sap.ui.view({
            id : "app",
            viewName : "sap.gss.program.view.App",
            type : "JS",
            viewData : { component : this }
        });

        var i18nModel = new sap.ui.model.resource.ResourceModel({
            bundleUrl : "i18n/appTexts_fr.properties"
            });

        oView.setModel(i18nModel, "i18n");      
        return oView;
    }
Run Code Online (Sandbox Code Playgroud)

Controller.js:

createApplication: function (oEvent) {

    if (!this.oDialogFragment) {
         this.oDialogFragment = sap.ui.xmlfragment("sap.gss.program.view.myFragment",
                                                   this);       
    }        
    this.oDialogFragment.open(); 

}
Run Code Online (Sandbox Code Playgroud)

fragment.xml:

<core:FragmentDefinition
  xmlns="sap.m"
  xmlns:core="sap.ui.core"
  xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1">
  <Dialog
    title="{i18n>Title}"
    class="sapUiPopupWithPadding" > …
Run Code Online (Sandbox Code Playgroud)

localization sapui5

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