【问题标题】:Spring OAuth2 on Android Exception: Didn't find class "javax.xml.transform.stax.StAXSource" on path: DexPathListAndroid异常上的Spring OAuth2:在路径上找不到类“javax.xml.transform.stax.StAXSource”:DexPathList
【发布时间】:2018-08-08 16:03:49
【问题描述】:

我尝试使用 spring 的 OAuth2 依赖项为服务器创建一个 android 客户端。问题是当我调用这个构造函数时:

OAuth2RestTemplate oAuthRestTemplate = new Auth2RestTemplate(resourceDetails);

我得到这个异常:

Didn't find class "javax.xml.transform.stax.StAXSource" on path: DexPathList

我使用使用 gradle 的 Android Studio,并且我包含这样的 OAuth2 依赖项:

dependencies {
    implementation 'org.springframework.security.oauth:spring-security-oauth2:2.3.0.RC1'
    ...
}

similar question 中,接受的答案建议包含 Spring REST 模板依赖项 (compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'),但是当我这样做时,我收到另一个错误,我也发布了 here

我认为不应包含 Spring rest-template 依赖项,因为它可能已经由 Spring OAuth 依赖项导入。这是真的吗?如果是,我该如何解决找不到另一个类(javax.xml.transform.stax.StAXSource)的问题?我认为找不到这个类的原因是因为我在使用this answer建议的自己的JDK实现的android上。

如果有人能帮我解决这个问题,将不胜感激。

【问题讨论】:

    标签: java android spring oauth-2.0 dependencies


    【解决方案1】:

    似乎需要另一个依赖项(spring-android-rest-template 依赖项),我不得不将它们都放入并排除重复的模块。我是这样做的:

    compile('org.springframework.android:spring-android-rest-template:2.0.0.M3') {
        exclude module: 'spring-android-core'
    }
    
    compile('org.springframework.security.oauth:spring-security-oauth2:2.3.0.RC1'){
        exclude module: 'spring-web'
    }
    

    【讨论】:

      猜你喜欢
      • 2014-08-27
      • 2017-08-13
      • 1970-01-01
      • 2016-02-04
      • 2017-09-12
      • 2014-05-29
      • 2015-07-01
      • 2018-12-30
      相关资源
      最近更新 更多