小编chi*_*fet的帖子

何时使用 @ImportAutoConfiguration 与 @Import

我对文档不太清楚何时使用其中一种或另一种。从我尝试过的事情来看,他们似乎都有相同的行为。到底有什么区别?

spring spring-boot

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

传递与签名不匹配的块参数

我正在使用基于块的API,偶然发现了一个场景,我传递的块参数的签名与方法所期望的typedef'd参数不匹配.令我惊讶的是,编译器似乎并不关心这一点,并且应用程序没有崩溃.这是预期的行为吗?例:

typedef void(^MyBlock)();
typedef void(^MyBlockWithParam)(id param);

- (void)doWork {
    MyBlockWithParam block1 = ^(id param) {
        NSLog(@"block1: %@", param);
    };

    MyBlock block2 = ^{
        NSLog(@"block2");
    };

    [self loadData:block1];
    [self loadData:block2];
}

- (void)loadData:(MyBlockWithParam)block {
    block(@"foo");
}
Run Code Online (Sandbox Code Playgroud)

objective-c objective-c-blocks

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

Sequelize正确执行多个创建+更新

我有一个cron作业,它擦除网站上的项目列表,然后在数据库中插入或更新记录.当我刮擦页面时,我想为尚未创建的新记录创建记录,否则更新任何现有记录.目前我正在做这样的事情:

// pretend there is a "Widget" model defined

function createOrUpdateWidget(widgetConfig) {
    return Widget.find(widgetConfig.id)
        .then(function(widget) {
            if (widget === null) {
                return Widget.create(widgetConfig);
            }
            else {
                widget.updateAttributes(widgetConfig);
            }
        });
}

function createOrUpdateWidgets(widgetConfigObjects) {
    var promises = [];

    widgetConfigObjects.forEach(function(widgetConfig) {
        promises.push(createOrUpdateWidget(widgetConfig));
    });

    return Sequelize.Promise.all(promises);
}


createOrUpdateWidgets([...])
    .done(function() {
        console.log('Done!');
    });
Run Code Online (Sandbox Code Playgroud)

这似乎工作正常,但我不确定我是否"正确"这样做.执行数据库交互的所有承诺是否需要以串行方式运行,或者我是如何定义它们的?有没有更好的方法来做这种事情?

promise sequelize.js

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

Spring Boot应用程序+ Kubernetes活动/准备情况检查

我正在构建一些Spring Boot微服务,这些服务将部署在Kubernetes(专用于AKS)集群中。我正计划将活动性和就绪性检查的probePath设置为同时指向执行器运行状况端点,但我想知道这是否不是最佳选择。我最初的想法是,检查路径将很有用(至少对于就绪状态而言),以便在Spring启动并能够处理请求之前,不向其发送流量。由于这些服务使用数据库连接,并且如果执行器运行状况指示器无法建立连接,则执行器运行状况指示器将报告状态为关闭,这不是一个好主意吗?

考虑到活动性,我认为它可能会一遍又一遍地回收豆荚/容器,即使(在数据库关闭的情况下)它可能无法解决任何问题。

准备就绪后,我认为如果数据库关闭,这可能会导致可用应用程序池为0。如果数据库关闭,该应用程序本身很有可能不是很有用,但是我认为某些部件可能仍然可以工作。

对于这种事情是否有建议的最佳实践?

spring-boot kubernetes spring-boot-actuator

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

Windows 8空白应用程序+ DEP0700错误

我发现了一些提到这个错误的帖子,但没有一个有帮助.我创建了一个新的C#Windows Store项目,当我尝试在模拟器上构建并运行它时,我在visual studio中收到以下错误:

Error   1   Error : DEP0700 : Registration of the app failed. error 0x80072EE4: The Visual Elements extension failed while processing the Notification element. (0x80073cf6)    TestDeploy
Run Code Online (Sandbox Code Playgroud)

以下是运行不同帖子中提到的Power Shell命令的详细信息:

12/18/2012 3:03:59 PM   404 Error   error 0x80073CF6: AppX Deployment operation failed. The specific error text for this failure is: error 0x80072EE4: The Visual Elements extension failed while processing the Notification element.  
12/18/2012 3:03:59 PM   401 Error   Deployment Register operation on Package cc8bb3bb-d444-4dbe-ae12-64684b12b727_1.0.0.0_neutral__2awvr17ztw74c from:  (C:\Users\myself\documents\visual studio 2012\Projects\TestDeploy\TestDeploy\bin\Debug\AppX\AppxManifest.xml)  failed with error 0x80073CF6. …
Run Code Online (Sandbox Code Playgroud)

c# visual-studio windows-8 windows-store windows-store-apps

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

AngularJS依赖注入交换实现

我还在学习AngularJS,并对他们的依赖注入风格有疑问.例如,假设我有一个DataProcessor服务,它有一个processData接受uri参数的方法,它需要读取该数据(可能是xml,json等),然后对它执行一些操作.该DataProcessor构造函数接受一个的实现DataReader,它知道如何读取某个文件类型的接口.以下是我所说的一些示例服务:

// implementations of the DataReader interface
myApp.service('XmlDataReader', function() {
    this.readData = function(uri) {
        // read xml data from uri
    }
}]);

myApp.service('JsonDataReader', function() {
    this.readData = function(uri) {
        // read json data from uri
    }
}]);

// data processing service that takes in an implementation of a DataReader
myApp.service('DataProcessor', ['DataReader', function(DataReader) {

    this.processData = function(uri) {
        var readData = DataReader.readData(uri);

        // process data and return it
    }
}]);
Run Code Online (Sandbox Code Playgroud)

从典型的依赖注入角度来看, …

angularjs angularjs-injector

7
推荐指数
2
解决办法
1839
查看次数

核心图形绘制带有边框的矩形

如何在一行中绘制带边框的矩形?

有单独的方法,如:

CGContextStrokeRect(context, someRectangle);
Run Code Online (Sandbox Code Playgroud)

CGContextFillRect(context, someRectangle);
Run Code Online (Sandbox Code Playgroud)

但有什么东西可以同时做到吗?

core-graphics objective-c ios

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

何时在ARC对象引用上使用__block关键字

我知道__block块的标量变量需要存储类型才能看到它们的更新,但是何时需要对象?我相信__weak应该在捕获要在块中使用的自引用时使用,但我不知道何时需要实际使用__block普通对象的存储类型.

objective-c objective-c-blocks automatic-ref-counting

6
推荐指数
1
解决办法
4724
查看次数

Weinre样式检查不适用于AngularJS

我正在尝试使用Weinre来调试AngularJS应用程序,但样式检查不起作用.我可以使用Weinre在页面上选择元素,但它从不显示来自CSS选择器的相关样式信息.我已经将它缩小到仅仅包括AngularJS(我使用的是版本1.2.5)在页面中断Weinre样式检查.我在网上发现了一些Weinre没有与AngularJS合作的参考文献(https://issues.apache.org/jira/browse/CB-2651),但是JIRA说它已经解决了.有任何想法吗?

angularjs weinre

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

Spring @Autowired行为在测试中与组件不同

@Autowired在编写测试时,规则/行为是否不同?似乎通过测试,您可以自动装配到具体类型,但如果您在其中尝试相同的事情@Component,它将失败.这是一个人为的例子,但这是我遇到的事情,我只是想更好地理解.

受控示例代码:

public interface Gizmo {

  void whirr();
}

@Configuration
public class GizmoConfiguration {

  @Bean
  @Profile("no-dependencies")
  public Gizmo fooGizmoBean() {
    return new FooGizmo();
  }

  @Bean
  @Profile("!no-dependencies")
  public Gizmo barGizmoBean() {
    return new BarGizmo();
  }

  public class FooGizmo implements Gizmo {
    @Override
    public void whirr() {
    }
  }

  public class BarGizmo implements Gizmo {
    @Override
    public void whirr() {
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

运行良好的测试:

@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles(Application.Profiles.NO_DEPENDENCIES)
public class TestClass {

  @Autowired
  private GizmoConfiguration.FooGizmo gizmo;

  @Test
  public void test() …
Run Code Online (Sandbox Code Playgroud)

spring spring-test spring-ioc

6
推荐指数
1
解决办法
600
查看次数