小编Edw*_*ard的帖子

GitLab 合并请求讨论中的“提交评论”和“立即添加评论”有什么区别?

我是第一次使用 GitLab 用户,在审查某人的合并请求时有点困惑。每当我添加评论时,我都会收到 2 个选项[Submit review][Add comment now].

GitLab 合并请求讨论

2者有什么区别?为什么需要2个选项?

gitlab merge-request

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

Java 如何知道使用 lambda 表达式调用哪个重载方法?(供应商、消费者、可调用……)

首先,我不知道如何恰当地表达这个问题,所以这是一个建议。

假设我们有以下重载方法:

void execute(Callable<Void> callable) {
    try {
        callable.call();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

<T> T execute(Supplier<T> supplier) {
    return supplier.get();
}

void execute(Runnable runnable) {
    runnable.run();
}
Run Code Online (Sandbox Code Playgroud)

从这张表出发,我从另一个问题中得到了答案

Supplier       ()    -> x
Consumer       x     -> ()
BiConsumer     x, y  -> ()
Callable       ()    -> x throws ex
Runnable       ()    -> ()
Function       x     -> y
BiFunction     x,y   -> z
Predicate      x     -> boolean
UnaryOperator  x1    -> x2
BinaryOperator x1,x2 -> x3
Run Code Online (Sandbox Code Playgroud)

以下是我在本地得到的结果:

Supplier       ()    -> …
Run Code Online (Sandbox Code Playgroud)

java lambda overloading function

23
推荐指数
2
解决办法
2142
查看次数

如何在Android中的<shape>中放置<vector>?

我正在尝试在Android中制作可自定义的图标.我制作了矢量元素,但现在我想给它一个圆形背景,所以我试着把它放在一个圆形的形状中.像这样:

<?xml version="1.0" encoding="utf-8"?>
<!-- drawable/circle_card_icon.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:height="24dp"
        android:width="24dp"
        android:viewportWidth="24"
        android:viewportHeight="24">
        <path android:fillColor="#000"
            android:pathData="M20,2H4A2,2 0 0,0 2,4V22L6,18H20A2,2 0 0,0 22,16V4A2,2 0 0,0 20,2M6,9H18V11H6M14,14H6V12H14M18,8H6V6H18" />
    </vector>
</shape>
Run Code Online (Sandbox Code Playgroud)

然而,这不起作用,我正在努力实现以下目标:
在此输入图像描述

通过仅使用矢量我不会得到背景.
(我用这个网站生成矢量)

android vector shape android-drawable

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

简单公共和私有(服务)方法上的 Micrometer @Timed 注释

我正在尝试使用千分尺注释应用普罗米修斯指标@Timed。我发现它们只适用于控制器端点,而不适用于“简单”的公共和私有方法。

给出这个例子:

@RestController
public class TestController {

    @GetMapping("/test")
    @Timed("test-endpoint") //does create prometheus metrics
    public String test() {
        privateMethod();
        publicMethod();
        return "test";
    }

    @Timed("test-private") //does NOT create prometheus metrics
    private void privateMethod() {System.out.println("private stuff");}

    @Timed("test-public") //does NOT create prometheus metrics
    public void publicMethod() {System.out.println("public stuff");}
}
Run Code Online (Sandbox Code Playgroud)

创建以下指标:

...
# HELP test_endpoint_seconds  
# TYPE test_endpoint_seconds summary
test_endpoint_seconds_count{class="com.example.micrometerannotationexample.TestController",exception="none",method="test",} 1.0
test_endpoint_seconds_sum{class="com.example.micrometerannotationexample.TestController",exception="none",method="test",} 0.0076286
# HELP test_endpoint_seconds_max  
# TYPE test_endpoint_seconds_max gauge
test_endpoint_seconds_max{class="com.example.micrometerannotationexample.TestController",exception="none",method="test",} 0.0076286
...
Run Code Online (Sandbox Code Playgroud)

没有找到@Timed("test-private")和 的指标@Timed("test-public"),这是为什么?


注意:我在这个 github thread上读到,Spring …

java metrics spring-boot prometheus spring-micrometer

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

在列上添加特定的自动过滤器

我正在尝试在列上设置过滤器.这是我在Interop中做到的方式:

private void CheckMasterFile(string path) {
    var xlApp = new Excel.Application();
    var xlWorkbook = xlApp.Workbooks.Open(path);
    Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];

    foreach (var project in projects) {
        if (string.IsNullOrEmpty(project.ProjectID.Value)) {
            continue;
        }

        var xlRange = xlWorksheet.UsedRange;
        if (xlWorksheet.AutoFilter != null) {
            xlWorksheet.AutoFilterMode = false;
        }
        xlRange.AutoFilter(Field: 2, Criteria1: project.ProjectID.Value);
        var result = xlRange.SpecialCells(Excel.XlCellType.xlCellTypeVisible, Type.Missing);//only shows filtered values
        double sum = 0;

        foreach (Excel.Range row in result.Rows) {
            if (row.Cells[2, 2].Value2() != null) {
                if (!NOT_ALLOWED_RUBRIQUES.Contains((string)row.Cells[2, 8].Value2())) {//check if rubrique is allowed or …
Run Code Online (Sandbox Code Playgroud)

c# excel autofilter epplus

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

如何在EPPlus中对行/列进行分组

有没有办法在EPPlus中实现这一目标?我在互联网上找到的唯一的事情就是对特定数据进行分组,例如:

AAA     --->    AAA     5 occurrences
AAA             BBB     2 occurences
BBB
BBB    
AAA
AAA
AAA
Run Code Online (Sandbox Code Playgroud)

但在截图中看起来并不像

c# excel openxml epplus

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

如何从 ResponseEntity 中的 Swagger/OpenAPI 中省略空字段?

我试图在我的 ResponseEntity 中省略空值。

我的控制器看起来像这样:

@RestController
public class FooController {

    //fields
    //constructor

    @PostMapping
    public ResponseEntity<CreateFooResponseV10> createFoo(@Valid @RequestBody CreateFooRequestV10 foo, HttpServletRequest request) {
        //some minor logic
        return new ResponseEntity<>(aFooResponseV10Builder()
                .withFirstName(foo.getFirstName())
                .withLastName(foo.getLastName())
                .withTestField(NULLABLE_OBJECT)
                .build(), ...);
    //I generated the builders from the output classes openapi-generator provided
    }
    // more stuff...
}
Run Code Online (Sandbox Code Playgroud)

When NULLABLE_OBJECTis equal tonull我希望从响应中省略该字段,如下所示:

{
  "firstName": "John",
  "lastName": "Doe"
}
Run Code Online (Sandbox Code Playgroud)

但我要么得到这些回应,这取决于我到目前为止的尝试:

{
  "firstName": "John",
  "lastName": "Doe",
  "testField": null
}
Run Code Online (Sandbox Code Playgroud)

或者

{
   "firstName": "John",
   "lastName": "Doe",
   "testField": {"present":false}
}
Run Code Online (Sandbox Code Playgroud)

我使用openapi-generator …

spring json swagger openapi openapi-generator

8
推荐指数
4
解决办法
6661
查看次数

angular2:Uncaught SyntaxError:意外的令牌<

Uncaught SyntaxError: Unexpected token <每当我尝试运行angular2应用程序时,我都会收到此错误.这只是基于angular2网站的路由"教程"的修改.

通常这些错误说明了我错误编写了一段代码.但是Chrome控制台告诉我在angular2 js文件中发生了错误.

阅读并试图从两者的答案Chrome Uncaught Syntax Error: Unexpected Token ILLEGAL ,并warning C4819: How to find the character that has to be saved in unicode?没有工作.猜测错误必须在我的boot.ts或app.component.ts中.

boot.ts

import {bootstrap}        from 'angular2/platform/browser';
import {ROUTER_PROVIDERS} from 'angular2/router';
import {AppComponent}     from './app.component';
import {HallService}     from './hall/hall.service';
bootstrap(AppComponent,[
    ROUTER_PROVIDERS,
    HallService
]);
Run Code Online (Sandbox Code Playgroud)

app.component.ts

import {Component} from 'angular2/core';
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
import {HallCenterComponent} from './hall/hall-center.component';

@Component({
    selector: 'my-app',
    template: `
    <h1 class="title">Component Router</h1>
    <a …
Run Code Online (Sandbox Code Playgroud)

javascript syntax-error token typescript angular

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

如何配置nginx的default.conf

我正在尝试配置default.conf/etc/nginx/conf.d显示位于 的简单登录页面/home/ubuntu/project-source/company/entry/index.html

据我所知,域已正确设置以指向服务器

A: test24.company.io -> <aws-elastic-IP>
Run Code Online (Sandbox Code Playgroud)

默认.conf:

server {
    listen       80;
    server_name  localhost;

    index index.html;

    location / {
        root   /home/ubuntu/project-source/company/entry;
    }
}

server {
    server_name test24.company.io www.test24.company.io;

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/test24.company.io/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/test24.company.io/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
    if ($host = test24.company.io) {
        return 301 https://$host$request_uri;
    } # managed by …
Run Code Online (Sandbox Code Playgroud)

dns nginx nginx-location nginx-config

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

是否可以在 Vue 中使 props 有条件,例如 prop2 取决于 prop1 的值?

我有一个用例,我需要将特定的错误消息传递给自定义组件。当且仅当某个 prop 设置为true。但我怀疑this.required道具中是否可用,因为它不会被初始化。

//custom component
props: {
  required: {
    type: Boolean,
    default: false
  },
  requiredErrorMsg: {
    type: String,
    default: '',
    required: this.required
  }
}
Run Code Online (Sandbox Code Playgroud)

如果 prop 丢失,Vue(或 eslint?)应该抛出警告或错误,具体取决于是否required设置为 true。

<Custom :required="true" /> //missing prop error
<Custom :required="true" required-error-msg="this is an error"/> //no issues
Run Code Online (Sandbox Code Playgroud)

目前使用:
nuxt v2.3.4
eslint v5.0.1

eslint vue.js nuxt.js

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