簡體   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)

執行上面的代碼片段后,我得到了一些錯誤。 喜歡-

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 解析器不能像上面那樣處理換行符。

代替

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

你需要使用

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM