如何通过抓取获得特定的依赖?

时间:2017-12-05 22:04:20

标签: groovy

我使用的是AWS SDK:

@Grab(group='com.amazonaws', module='aws-java-sdk-elasticbeanstalk', version='1.11.232')

import com.amazonaws.regions.Regions
import com.amazonaws.services.elasticbeanstalk.*
import com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentsRequest
import com.amazonaws.auth.AWSStaticCredentialsProvider
import com.amazonaws.auth.BasicAWSCredentials
import com.amazonaws.auth.EnvironmentVariableCredentialsProvider

class testAws {
    static Object test (){

        def awsCreds = new BasicAWSCredentials('sdfsdfdf', 'sdfsdfdsf')
        def ebClient = new AWSElasticBeanstalkClientBuilder()
            .withRegion(Regions.valueOf('US-EAST-1'))
            .withCredentials(new AWSStaticCredentialsProvider (awsCreds))
            .build()

        ebClient.describeEnvironments(
            new DescribeEnvironmentsRequest().withEnvironmentNames('zzzzz')
        ).getEnvironments()
    }
}

我收到此错误:

Caught: java.lang.NoSuchMethodError: `org.apache.http.conn.ssl.SSLConnectionSocketFactory.<init>(Ljavax/net/ssl/SSLContext;Ljavax/net/ssl/HostnameVerifier;)V`

做一些谷歌搜索我发现aws sdk取决于http库的特定版本。如果这是一个java项目,我会在我的pom或gradle配置中定义该特定版本。我如何抓住这个?

要明确我不需要明确地抓取http,因为它作为aws sdk的依赖项被拉入。问题是我在本地安装了不同的(较新的)版本。即使我明确地抓住旧版本,它仍然会抛出此错误。如果我从我的系统中卸载新版本它可以工作。但我想在groovy中强制执行此操作,而不必修改本地environemnt。

0 个答案:

没有答案