【问题标题】:Facing issue while executing the Groovy code执行 Groovy 代码时面临的问题
【发布时间】:2022-07-04 22:39:03
【问题描述】:
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', 授权)

在执行上面的代码 sn-p 之后,我得到了一些错误。喜欢-

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

谁能帮我解决这个问题??

谁能帮我解决

【问题讨论】:

    标签: groovy groovyshell groovy-console


    【解决方案1】:

    Groovy 解析器无法像上面那样处理换行符。

    代替

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

    你需要使用

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

    所以解析器可以知道你的意思

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-07
      • 1970-01-01
      • 2021-04-11
      • 2021-12-27
      • 2021-11-22
      • 2021-09-09
      • 1970-01-01
      • 2017-09-11
      相关资源
      最近更新 更多