微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

spring-message依赖连接问题

如何解决spring-message依赖连接问题

我最近按照本教程将 Spring 消息传递模块连接到我的 libgdx 项目,以便优雅地使用套接字:https://nexocode.com/blog/posts/spring-dependencies-in-gradle/

然后任务 android:mergeDebugJavaResource 发誓我有多个文件 meta-inf/web-fragment.xml

* What went wrong:
Execution Failed for task ':android:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > More than one file was found with OS independent path 'meta-inf/web-fragment.xml'. 

由于问题出现在启动而不是构建,所以我向您展示gradle.build的

build.gradle(app_name)

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://plugins.gradle.org/m2/" }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.3'
        classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.12'
        classpath 'com.google.gms:google-services:4.3.5'
    }
}

plugins {
    id 'java-library'
    id 'org.springframework.boot' version '2.1.0.RELEASE'
}

allprojects {
    apply plugin: "eclipse"

    version = '1.0'
    ext {
        appName = "bogatiry-online"
        gdxVersion = '1.9.14'
        robovmVersion = '2.3.12'
        Box2DLightsversion = '1.5'
        ashleyVersion = '1.7.3'
        aiVersion = '1.8.2'
        gdxcontrollersversion = '2.1.0'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        google()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}

project(":desktop") {
    apply plugin: "java-library"


    dependencies {
        implementation project(":core")
        api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
    }
}

project(":android") {
    apply plugin: "com.android.application"

    configurations { natives }

    dependencies {
        implementation project(":core")
        api "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
        api "com.badlogicgames.Box2dlights:Box2dlights:$Box2DLightsversion"
    }
}

project(":ios") {
    apply plugin: "java-library"
    apply plugin: "robovm"


    dependencies {
        implementation project(":core")
        api "com.mobidevelop.robovm:robovm-rt:$robovmVersion"
        api "com.mobidevelop.robovm:robovm-cocoatouch:$robovmVersion"
        api "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
        
    }
}

project(":core") {
    apply plugin: "java-library"

    dependencies {
        api "com.badlogicgames.gdx:gdx:$gdxVersion"
        api "com.badlogicgames.Box2dlights:Box2dlights:$Box2DLightsversion"
        api "com.underwaterapps.overlap2druntime:overlap2d-runtime-libgdx:0.1.0"
        api "com.kotcrab.vis:vis-ui:1.3.0"
    }
}

build.gradle(:core)

plugins {
    id 'org.springframework.boot'
    id 'io.spring.dependency-management'
}
sourceCompatibility = 1.7
dependencies {
    //Apache
    implementation group: 'org.apache.httpcomponents',name: 'httpclient',version: '4.5.13'

    //Json
    implementation group: 'com.fasterxml.jackson.core',name: 'jackson-databind',version: '2.12.3'

    //Lombok
    compileOnly group: 'org.projectlombok',name: 'lombok',version: '1.18.20'

    //Spring
    api platform('org.springframework.boot:spring-boot-dependencies:2.1.0.RELEASE')
    implementation 'org.springframework.boot:spring-boot-starter-websocket'
    dependencies {
        constraints {
            implementation 'org.springframework.boot:spring-boot-starter-websocket:2.4.5'
        }
    }
}
[compileJava,compileTestJava]*.options*.encoding = 'UTF-8'

sourceSets.main.java.srcDirs = [ "src/" ]

eclipse.project.name = appName + "-core"

bootJar {
    enabled = false
}

jar {
    enabled = true
}

build.gradle(:android)(虽然我觉得问题不在里面,没报错的时候我没改)

apply plugin: 'com.google.gms.google-services'

android {
    buildToolsversion "30.0.3"
    compileSdkVersion 30
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
        }

    }
    packagingOptions {
        exclude 'meta-inf/robovm/ios/robovm.xml'
    }
    defaultConfig {
        applicationId "com.drownedman.bogatiry"
        minSdkVersion 26
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    packagingOptions {
        exclude 'meta-inf/DEPENDENCIES'
        exclude 'meta-inf/LICENSE'
        exclude 'meta-inf/LICENSE.txt'
        exclude 'meta-inf/license.txt'
        exclude 'meta-inf/NOTICE'
        exclude 'meta-inf/NOTICE.txt'
        exclude 'meta-inf/notice.txt'
        exclude 'meta-inf/ASL2.0'
        exclude("meta-inf/*.kotlin_module")
    }
}

// called every time gradle gets executed,takes the native dependencies of
// the natives configuration,and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives {
    doFirst {
        file("libs/armeabi/").mkdirs()
        file("libs/armeabi-v7a/").mkdirs()
        file("libs/arm64-v8a/").mkdirs()
        file("libs/x86_64/").mkdirs()
        file("libs/x86/").mkdirs()

        configurations.natives.copy().files.each { jar ->
            def outputDir = null
            if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
            if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
            if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
            if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
            if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
            if(outputDir != null) {
                copy {
                    from zipTree(jar)
                    into outputDir
                    include "*.so"
                }
            }
        }
    }
}

tasks.whenTaskAdded { packageTask ->
    if (packageTask.name.contains("package")) {
        packageTask.dependsOn 'copyAndroidNatives'
    }
}

task run(type: Exec) {
    def path
    def localProperties = project.file("../local.properties")
    if (localProperties.exists()) {
        Properties properties = new Properties()
        localProperties.withInputStream { instr ->
            properties.load(instr)
        }
        def sdkDir = properties.getProperty('sdk.dir')
        if (sdkDir) {
            path = sdkDir
        } else {
            path = "$System.env.ANDROID_HOME"
        }
    } else {
        path = "$System.env.ANDROID_HOME"
    }

    def adb = path + "/platform-tools/adb"
    commandLine "$adb",'shell','am','start','-n','com.drownedman.bogatiry/com.drownedman.bogatiry.AndroidLauncher'
}

dependencies {
    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:26.8.0')

    // Declare the dependency for the Firebase Authentication library
    // When using the BoM,you don't specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-auth'
    implementation 'com.google.firebase:firebase-database:19.7.0'
    implementation 'com.google.android.gms:play-services-auth:18.0.0'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
}

eclipse.project.name = appName + "-android"

我试过了

  1. 文件 -> 使缓存无效/重新启动。
  2. 检查了版本的兼容性,似乎一切正常。
  3. 排除了一些常见于此类错误中的“meta-inf /”文件 (More than one file was found with OS independent path 'META-INF/LICENSE')。我可以用同样的方式排除这个文件,但随后我在另一个文件中遇到了类似的错误,然后是另一个文件,依此类推。

但没用

解决方法

回答我自己的问题,我只是排除了这一长串文件,如类似问题 More than one file was found with OS independent path 'META-INF/LICENSE'

exclude 'META-INF/web-fragment.xml'
exclude 'META-INF/LICENSE.md'
exclude 'META-INF/NOTICE.md'
exclude 'META-INF/spring.schemas'
exclude 'META-INF/spring.tooling'
exclude 'META-INF/spring.handlers'
exclude 'META-INF/spring-configuration-metadata.json'
exclude 'META-INF/spring.factories'
exclude 'META-INF/additional-spring-configuration-metadata.json'

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?