Gradle失败后的Spring RestTemplate

时间:2018-08-06 07:44:11

标签: java spring gradle resttemplate

我正在研究使用spring android rest模板和gluon的gradle项目。我实例化RestTemplate时得到了这个异常:

    Working Directory: C:\Users\Roy 1\eclipse\workspaces\wake\restTempTest\restTempTestApp
Gradle User Home: C:\Users\Roy 1\.gradle
Gradle Distribution: Gradle wrapper from target build
Gradle Version: 4.3.1
Java Home: C:\Program Files\Java\jdk1.8.0_131
JVM Arguments: None
Program Arguments: None
Build Scans Enabled: false
Offline Mode Enabled: false
Gradle Tasks: run

:restTempTestApp:compileJava
:restTempTestApp:processResources UP-TO-DATE
:restTempTestApp:classes
:restTempTestApp:compileDesktopJava NO-SOURCE
:restTempTestApp:processDesktopResources NO-SOURCE
:restTempTestApp:desktopClasses UP-TO-DATE
:restTempTestApp:runAug 06, 2018 10:33:12 AM com.gluonhq.charm.down.Platform <clinit>
SEVERE: javafx.platform is not defined. Desktop will be assumed by default.
java.lang.NoClassDefFoundError: android/os/Build$VERSION
    at org.springframework.http.client.support.HttpAccessor.<init>(HttpAccessor.java:52)
    at org.springframework.http.client.support.InterceptingHttpAccessor.<init>(InterceptingHttpAccessor.java:35)
    at org.springframework.web.client.RestTemplate.<init>(RestTemplate.java:169)
    at org.springframework.web.client.RestTemplate.<init>(RestTemplate.java:158)
    at com.gluonapplication.GluonApplication.postInit(GluonApplication.java:23)
    at com.gluonhq.charm.glisten.application.MobileApplication.a(SourceFile:269)
    at com.gluonhq.charm.glisten.application.MobileApplication.start(SourceFile:232)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: android.os.Build$VERSION
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 16 more


BUILD SUCCESSFUL in 21s
3 actionable tasks: 2 executed, 1 up-to-date

这是我的build.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.3.12'
    }
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'io.rainrobot.wake.android.GluonApplication'

dependencies {
    compile 'com.gluonhq:charm:5.0.0'

    compile group: 'org.springframework.android', name: 'spring-android-rest-template', version: '1.0.1.RELEASE'

    compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.3'

    compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version: '1.0.0.Final' 

    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.6'
}

jfxmobile {
    downConfig {
        version = '3.8.0'
        // Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
        plugins 'display', 'lifecycle', 'statusbar', 'storage'
    }
    android {
        compileSdkVersion '27'    
        buildToolsVersion "27.0.3"

        manifest = 'src/android/AndroidManifest.xml'
//        dexOptions {
//          preDexLibraries = false
//      }
       packagingOptions {
            pickFirst 'META-INF/notice.txt'
            pickFirst 'META-INF/license.txt'
            pickFirst 'META-INF/spring.tooling'
            pickFirst 'META-INF/spring.schemas'
            pickFirst 'META-INF/spring.handlers'
            pickFirst 'META-INF/LICENSE'
            pickFirst 'META-INF/NOTICE'
        }
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
        forceLinkClasses = [
                'com.gluonhq.**.*',
                'javax.annotations.**.*',
                'javax.inject.**.*',
                'javax.json.**.*',
                'org.glassfish.json.**.*'
        ]
    }
}

我尝试过几次更改sdk版本,但似乎没有效果。

如果没有解决方案,spring客户端是否有替代方法可以让我继续使用现有代码? (我也在使用ResponseEntity,HttpHeaders和HttpEntity)

0 个答案:

没有答案