使用android studio开发Spring Boot项目,报错

使用android studio开发Spring Boot项目,报错:Caused by: java.lang.ClassNotFoundException: org.springframework.web.reactive.config.WebFluxConfigurer。添加相关依赖:compile("org.springframework:spring-web-reactive:5.0.0.M1")后报错(如下),求大佬指导:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileJava'.
> Could not resolve all files for configuration ':app:compileClasspath'.
   > Could not find org.springframework:spring-web-reactive:5.0.0.M1.
     Required by:
         project :app

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

build.gradle(app)如下:

apply plugin: 'java'
apply plugin: 'org.springframework.boot'


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    compile('org.springframework.boot:spring-boot-starter-parent:2.3.4.RELEASE')
    compile('org.springframework.boot:spring-boot-starter-web:2.3.4.RELEASE')
    compile('com.aliyun.oss:aliyun-sdk-oss:3.15.0')
    compile('com.aliyun:aliyun-java-sdk-sts:3.0.0')
    compile('com.aliyun:aliyun-java-sdk-core:4.4.6')
    compile('org.projectlombok:lombok:1.16.10')
    compile('io.springfox:springfox-boot-starter:3.0.0')
    compile('org.springframework:spring-web:5.3.14')
    compile('org.springframework:spring-web-reactive:5.0.0.M1')
}

build.gradle(项目)如下:

buildscript {
    
    repositories {
        mavenLocal()
        mavenCentral()
        
    }
    dependencies {
        classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.9.RELEASE'
        

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

该回答通过自己思路及引用到GPTᴼᴾᴱᴺᴬᴵ搜索,得到内容具体如下:

您的问题可能是由于Spring Boot版本与Spring Web Reactive版本不兼容导致的。
在Spring Boot 2.3.4.RELEASE中,Spring Web Reactive的版本应该是5.2.x而不是5.0.0.M1。
请尝试将依赖项中的Spring Web Reactive版本更改为5.2.x,并重新运行Gradle构建。

以下是更改后的build.gradle(app)文件:

apply plugin: 'java'
apply plugin: 'org.springframework.boot'
 
 
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    compile('org.springframework.boot:spring-boot-starter-parent:2.3.4.RELEASE')
    compile('org.springframework.boot:spring-boot-starter-web:2.3.4.RELEASE')
    compile('com.aliyun.oss:aliyun-sdk-oss:3.15.0')
    compile('com.aliyun:aliyun-java-sdk-sts:3.0.0')
    compile('com.aliyun:aliyun-java-sdk-core:4.4.6')
    compile('org.projectlombok:lombok:1.16.10')
    compile('io.springfox:springfox-boot-starter:3.0.0')
    compile('org.springframework:spring-web:5.3.14')
    compile('org.springframework:spring-webflux:5.2.14.RELEASE')
}
 
build.gradle(项目)文件保持不变。

如果您在更改依赖项版本后仍然遇到问题,请尝试在Gradle构建中添加--refresh-dependencies选项来刷新依赖项缓存,例如:

./gradlew clean build --refresh-dependencies

希望这可以帮助您解决问题。

如果以上回答对您有所帮助,点击一下采纳该答案~谢谢

为啥要用studio ,intellij 不行吗