小编San*_*ose的帖子

Jackson Json反序列化:未被识别的字段"......",未标记为可忽略

我收到以下错误,我发现没有解决方法对我有所帮助:

无法识别的字段"GaugeDeviceId"(Class GaugeDevice),未标记为可忽略

问题似乎是,服务返回带有大写字母的属性名称,而类属性以较低的字母开头.

我试过了:

  1. 将propertyNames更改为第一个大写字母 - 相同的错误
  2. 添加@JsonProperty("SerialNo")到属性实例化 - 相同的错误
  3. 添加@JsonProperty("SerialNo")到相应的getter - 相同的错误
  4. 添加@JsonProperty("SerialNo")到相应的setter - 相同的错误
  5. 添加@JsonProperty("SerialNo")到所有这些(只是为了好玩) - 同样的错误

(注意:@JsonProperty("SerialNo")只是一个例子)

奇怪的是,那个注释:@JsonIgnoreProperties(ignoreUnknown = true)应该完全抑制那个错误,但它仍在触发......

这里的课程:(注意:不完整)

@JsonIgnoreProperties(ignoreUnknown = true)
public class GaugeDevice 
{
    private int gaugeDeviceId;
    private Date utcInstallation;
    private String manufacturer;
    private float valueOffset;
    private String serialNo;
    private String comment;
    private int digitCount;
    private int decimalPlaces;

    @JsonProperty("SerialNo")
    public String getSerialNo() {
        return serialNo;
    }

    public void setSerialNo(String serialNo) …
Run Code Online (Sandbox Code Playgroud)

java json jackson

19
推荐指数
5
解决办法
8万
查看次数

错误:方法"props"仅用于在单个节点上运行.2找到了

it('should call setCampaignDate on click', function () {
    let spySetCampaign = sinon.spy(wrapper.instance(), 'setCampaignDate');
    let datePickers = wrapper.find('.campaign-date-tab').dive().find(Datepicker);
    assert.equal(datePickers.length, 2);
    console.log(datePickers);
    var date = new Date();

    for (let index = 0; index < datePickers.length; index++) {
      datePickers.simulate('change'); 
      sinon.assert.calledOnce(spySetCampaign.withArgs(date, 'startDate'));
    }


  });
Run Code Online (Sandbox Code Playgroud)

我正在尝试模拟我的"更改"功能并尝试测试是否调用'setCampaignDate'.这里的问题是find返回的浅组件的长度是2:

let datePickers = wrapper.find('.campaign-date-tab').dive().find(Datepicker);
Run Code Online (Sandbox Code Playgroud)

当试图在'datepickers'上调用模拟时,它会产生如下错误:

'Error: Method “props” is only meant to be run on a single node. 2 found instead.'.

不确定如何模拟节点大于1的组件.

reactjs chai-enzyme

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

拆分字符串并将其存储到HashMap java 8中

我想分割下面的字符串并将其存储到HashMap中.

String responseString = "name~peter-add~mumbai-md~v-refNo~"; 
Run Code Online (Sandbox Code Playgroud)

首先,我使用分隔符连字符( - )拆分字符串并将其存储到ArrayList中,如下所示:

 public static List<String> getTokenizeString(String delimitedString, char separator) {
    final Splitter splitter = Splitter.on(separator).trimResults();
    final Iterable<String> tokens = splitter.split(delimitedString);
    final List<String> tokenList = new ArrayList<String>();
    for(String token: tokens){
        tokenList.add(token);
    }
    return tokenList;
}
List<String> list = MyClass.getTokenizeString(responseString, "-");
Run Code Online (Sandbox Code Playgroud)

然后使用下面的代码将其转换为使用流的HashMap.

HashMap<String, String> = list.stream()
                          .collect(Collectors.toMap(k ->k.split("~")[0], v -> v.split("~")[1]));
Run Code Online (Sandbox Code Playgroud)

流收集器不起作用,因为没有refNo的值.

如果我在ArrayList中有偶数个元素,它可以正常工作.

有办法处理这个吗?还建议我如何使用流来执行这两个任务(我不想使用getTokenizeString()方法)使用流java 8.

java arraylist hashmap java-8 java-stream

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

InvalidOperationException:没有为方案“CookieSettings”注册身份验证处理程序。您是否忘记调用 AddAuthentication()

我正在使用 ASP.Net MVC core 2.1 开发一个应用程序,其中不断出现以下异常。

“InvalidOperationException:没有为方案‘CookieSettings’注册身份验证处理程序。注册的方案是:Identity.Application、Identity.External、Identity.TwoFactorRememberMe、Identity.TwoFactorUserId。您是否忘记调用 AddAuthentication().AddSomeAuthHandler?”

我浏览了文章并做了必要的更改,但例外情况仍然相同。我不知道下一步该做什么。

以下是我的startup.cs

public Startup(IConfiguration configuration)
{
    Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
    services.Configure<CookiePolicyOptions>(options =>
    {
        // This lambda determines whether user consent for non-essential cookies is needed for a given request.
        options.CheckConsentNeeded = context => true;
        options.MinimumSameSitePolicy = SameSiteMode.None;
    });

    services.AddDbContext<Infrastructure.Data.ApplicationDbContext>(options =>
        options.UseSqlServer(
            Configuration.GetConnectionString("DefaultConnection"))); …
Run Code Online (Sandbox Code Playgroud)

c#

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

EBADPLATFORM - inotify@1.4.2 平台不受支持

npm ERR! code EBADPLATFORM

npm ERR! notsup Unsupported platform for inotify@1.4.2: wanted {"os":"linux","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! notsup Valid OS:    linux

npm ERR! notsup Valid Arch:  any

npm ERR! notsup Actual OS:   win32

npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:

npm ERR!     C:\Users\lenovo\AppData\Roaming\npm-cache\_logs\2018-11-14T06_22_08_427Z-debug.log
Run Code Online (Sandbox Code Playgroud)

gulp-sass bootstrap-4

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

杰克逊错误:没有适合简单类的构造函数

我很麻烦,这是我想用Jackson 2.3.2进行序列化/反序列化的类。序列化工作正常,但反序列化效果不好。

我有如下异常:

找不到适合类型[简单类型,类Series]的构造函数:无法从JSON对象实例化(需要添加/启用类型信息吗?)

最奇怪的是,如果我评论构造函数,它会完美地工作!

public class Series {

private int init;
private String key;
private String color;

public Series(String key, String color, int init) {
    this.key = key;
    this.init = init;
    this.color = color;
}

//Getters-Setters

}
Run Code Online (Sandbox Code Playgroud)

而我的单元测试:

public class SeriesMapperTest {

private String json = "{\"init\":1,\"key\":\"min\",\"color\":\"767\"}";
private ObjectMapper mapper = new ObjectMapper();

@Test
public void deserialize() {
    try {
        Series series = mapper.readValue(json, Series.class);
    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }
}
}
Run Code Online (Sandbox Code Playgroud)

这种异常是从方法抛出deserializeFromObjectUsingNonDefault()BeanDeserializerBase杰克逊LIB的。 …

java json jackson

5
推荐指数
1
解决办法
4722
查看次数

如何在TeamCity中重置构建参数而不必单击重置按钮

在TeamCity构建配置中,我添加了一个带有名称"system.UploadCdn" 和规范的System参数,如下所示:

 "checkbox description='UploadCdn' label='UploadCdn' display='prompt' checkedValue='Upload'"
Run Code Online (Sandbox Code Playgroud)

我需要在构建完成后将此参数重置为"Unchecked State",而不必单击Reset链接.根据是否有一种方法可以强制TeamCity中的参数的默认值,并且一旦设置了不同的值,就不会丢失它?,我已经添加了最后一个构建步骤,如下所示.

Runner type: PowerShell Script : Source Code Script Source: ##teamcity[setParameter name='UploadCdn' value=' '] Script execution mode : Execute .ps1 from external file
Run Code Online (Sandbox Code Playgroud)

但它没有用.我错过了什么?

teamcity

5
推荐指数
0
解决办法
355
查看次数

Junit 使用 eq() 参数匹配器与直接传递字符串

eq()如果直接传递字符串会做同样的事情,那么参数匹配器有什么用呢?

例如的行为

when(method.foo("test")).thenReturn("bar");
Run Code Online (Sandbox Code Playgroud)

类似于

when(method.foo(ArgumentMatcher.eq("test"))).thenReturn("bar");
Run Code Online (Sandbox Code Playgroud)

junit mockito

5
推荐指数
1
解决办法
5446
查看次数

ECS从EC2迁移到Fargate

我正在尝试从Amaxon ECS EC2迁移到Fargate。在这里,我根据https://aws.amazon.com/blogs/compute/migrating-your-amazon-ecs-containers-to-aws-fargate/的建议进行了一些更改。我正在使用Amazon cloudformation创建/更新资源。

ECSTaskDefinition:
    Type: AWS::ECS::TaskDefinition
    Properties:
        Family : !Join ["_", [!Ref "AppName", !Ref "ComponentName", !Ref "TargetEnv" ]]
        NetworkMode: "awsvpc"
        ExecutionRoleArn: arn:aws:iam::${AWS::AccountId}:role/ecsTaskExecutionRole
        TaskRoleArn: 
            Fn::Sub: 
                [ 
                    "arn:aws:iam::${AWS::AccountId}:role/exec_dp_${TargetEnv}",
                    { 
                        TargetEnv: !Ref "TargetEnv"
                    }
                ]
        RequiresCompatibilities:
          - "FARGATE"
        Memory: "512"
        Cpu: '256'
        ContainerDefinitions:
Run Code Online (Sandbox Code Playgroud)

这里的问题是,当我尝试创建堆栈时,出现以下错误:

无法承担服务链接角色。请确认ECS服务链接角色存在

我还尝试过创建类似于以下内容的服务链接角色:

AwsEcsTaskExecutionRole:
     Type: AWS::IAM::Role
     Properties:
        Path: /
        AssumeRolePolicyDocument:
             Version: 2012-10-17
             Statement:
                     - Effect: Allow
             Principal:
             Service: ecs.amazonaws.com
             Action: sts:AssumeRole
        ManagedPolicyArns:
             - arn:aws:iam::aws:policy/aws-service-role/AmazonECSServiceRolePolicy
Run Code Online (Sandbox Code Playgroud)

然后将其指定为ExecutionRoleArn:!GetAtt AwsEcsTaskExecutionRole.Arn

它不起作用。关于任何方向都将真正有帮助。

amazon-web-services aws-cloudformation aws-fargate

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

Ant 设计:getFieldDecorator()

import {
 Form, Input, Tooltip, Icon
} from 'antd';
 import React , {Component }from 'react';
import ReactDOM from 'react-dom';

export default class RegistrationForm extends Component {
     state = {
     confirmDirty: false,
     autoCompleteResult: [],
     };

     handleSubmit = (e) => {
         e.preventDefault();
         this.props.form.validateFieldsAndScroll((err, values) => {
         if (!err) {
            console.log('Received values of form: ', values);
          }
       });
       }

     handleConfirmBlur = (e) => {
         const value = e.target.value;
         this.setState({ confirmDirty: this.state.confirmDirty || !!value                
         });
         }

        render() {
           console.log(this.props.form)
             const { getFieldDecorator } = …
Run Code Online (Sandbox Code Playgroud)

reactjs ant-design-pro

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

MongoDB 3.6的AggregateCursor问题

我已将MongoDB更新为3.6版本.我在CentOS 7和PHP 5.5.38上使用PHP MongoClient.如果我运行MongoDB库的aggregateCursor方法,通过http://php.net/manual/en/mongocollection.aggregatecursor.php中报告的第一个示例,我获得以下错误消息,如下所示:

PHP Fatal error:  Uncaught exception 'MongoCursorException' with message '95.110.150.99:27017: the command cursor did not return a correctly structured response' 
Run Code Online (Sandbox Code Playgroud)

你对这种行为有什么看法吗?

php aggregate-functions mongodb

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

对列表进行排序

所以我有一个如下列表:

points = [[0, 0], [5, 3], [0, 5], [0, 2], [1, 3], [5, 3]]
Run Code Online (Sandbox Code Playgroud)

我一直在用

points.sort(key=lambda pair: pair[0])
Run Code Online (Sandbox Code Playgroud)

对列表进行排序.但是这只是在不看第二个值的情况下按第一个值排序.

此代码的结果如下:

[[0, 0], [0, 5], [0, 2], [1, 3], [5, 3], [5, 3]]
Run Code Online (Sandbox Code Playgroud)

但是,我想排序是这样的,结果是:

[[0, 0], [0, 2], [0, 5], [1, 3], [5, 3], [5, 3]]
Run Code Online (Sandbox Code Playgroud)

我该怎么做?

此外,虽然我们在这,我如何删除此列表中的重复项?最终结果应该是:

[[0, 0], [0, 2], [0, 5], [1, 3], [5, 3]]
Run Code Online (Sandbox Code Playgroud)

python sorting

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

全新安装:httpd.service:找不到单元

目前,我正在尝试遵循此指南:https : //marxtudor.com/how-to-install-wordpress-using-ssh-on-centos-vps/

我正在使用Google Cloud Platform(要测试的免费版本),并且创建了新的CentOS 7 VM。上面的指南是我填写的第一个命令,但我不断收到此错误:

我遵循了如此多的教程,创建了一个新的VM,并且每次遇到此错误时,它都不知道httpd命令。.我什至删除了该项目并重新开始,但还是没有运气。

[rsa-key-XXXXXX]$ sudo service httpd restart

Redirecting to /bin/systemctl restart httpd.service

Failed to restart httpd.service: Unit not found.


[rsa-key-XXXXXX]$ httpd -t

-bash: httpd: command not found

[rsa-key-XXXXXX]$
Run Code Online (Sandbox Code Playgroud)

有人可以让我知道这可能是什么原因吗?

提前致谢!

apache wordpress centos google-cloud-platform centos7

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