我使用具有以下依赖关系的AWS Java S3 SDK。
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.11.155</version>
</dependency>
Java的一切都很好用:
BasicAWSCredentials credentials = new BasicAWSCredentials(key, secret);
AmazonS3 s3 = AmazonS3ClientBuilder
.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.withRegion(region)
.build();
如果我尝试通过Groovy脚本执行确切的操作:
def credentials = new BasicAWSCredentials(key, secret);
def s3 = AmazonS3ClientBuilder
.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.withRegion(s3region)
.build()
我得到一个例外:
Caught: javax.xml.stream.FactoryConfigurationError:
Provider com.bea.xml.stream.MXParserFactory not found
明确地将stax依赖项添加到我的.pom开始在其他地方给我冲突的类。
使用Groovy有一些技巧吗?
答案 0 :(得分:0)
尝试排除stax-api:
@GrabConfig(systemClassLoader = true)
@Grab('stax:stax:1.2.0')
@GrabExclude('stax:stax-api')
拉进去只是给了我:
java.lang.LinkageError: loader constraint violation: when resolving field "DATETIME" the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the referring class, javax/xml/datatype/DatatypeConstants, and the class loader (instance of <bootloader>) for the field's resolved type, javax/xml/namespace/QName, have different Class objects for that type
stax-api依赖项的javax.xml.namespace.QName类与JRE(https://docs.oracle.com/javase/7/docs/api/javax/xml/namespace/QName.html)提供的类冲突。