简体   繁体   English

执行 Groovy 代码时面临的问题

[英]Facing issue while executing the Groovy code

def hawkClient = new com.wealdtech.hawk.HawkClient.
    Builder()
    .credentials(new com.wealdtech.hawk.HawkCredentials.Builder()
            .keyId("your-hawk-hey-id")
            .key("your-hawk-key")
            .algorithm(Algorithm.SHA256)
            .build())
    .build();

def authorization = hawkClient
    .generateAuthorizationHeader(sampler.getUrl().toURI(), sampler.getMethod(), sampler.getArguments().getArgument(0).getValue())

vars.put('authorization', authorization)

after execute the above code snippet I got some error.执行上面的代码片段后,我得到了一些错误。 like-喜欢-

org.codehaus.groovy.control.MultipleCompilationErrorsException: 
startup failed:
/home/cg/root/62c2edae2dde2/main.groovy: 1: unexpected token: . @ 
line 1, column 51.
    com.wealdtech.hawk.HawkClient.
                             ^
1 error

can anyone please help me to fix this issue ??谁能帮我解决这个问题??

can anyone please help me to fix谁能帮我解决

The Groovy parser can't handle newlines as you have it above. Groovy 解析器不能像上面那样处理换行符。

Instead of代替

def hawkClient = new com.wealdtech.hawk.HawkClient.
    Builder()

You need to use你需要使用

def hawkClient = new com.wealdtech.hawk.HawkClient.Builder()

So the parser can know what you mean to do所以解析器可以知道你的意思

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM