Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

Gradle builds successfully Spring Boot project, but the launching on local host fails

I've got a problem with my latest Gradle Spring Boot project called CPR.

I'm using Gradle 6.7.1. and I've spent a whole day on making it built, as previously I was using the older version and since then the attribute names has changed a lot (for instance implementation instead of compile in dependencies block, etc.), although on central Maven repository's site, dependendencies are still in their old form... :)
After several tries, I finally managed to build the project (by using gradle build command in IntelliJ's console).
I could see that Gradle downloaded all dependencies and there were no errors in the console.
Here's how the working build.gradle looks like:

buildscript {
    ext {
        springBootVersion = '2.4.2'
    }
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        dependencies {
            classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
            classpath "io.spring.gradle:dependency-management-plugin:1.0.11.RELEASE"
        }
    }
}

plugins {
    id "org.springframework.boot" version "1.5.7.RELEASE"
    id "io.spring.dependency-management" version "1.0.11.RELEASE"
    id 'java'
    id 'war'
}

apply plugin: "org.springframework.boot"
apply plugin: "io.spring.dependency-management"
apply plugin: "java"
apply plugin: "war"

war {
    archiveBaseName = 'CprUI'
    archiveVersion = '1.0.0-SNAPSHOT'
}

test {
    exclude '**/*'
}

repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    implementation "org.springframework.boot:spring-boot-starter-thymeleaf"
    implementation "org.springframework.boot:spring-boot-starter-actuator"
    implementation "org.springframework.boot:spring-boot-starter-security"
    implementation "org.springframework.ldap:spring-ldap-core"
    implementation "org.springframework.security:spring-security-ldap"
    implementation "org.springframework:spring-tx"
    implementation "com.unboundid:unboundid-ldapsdk"
    implementation "org.springframework.boot:spring-boot-starter-data-jpa"
    implementation "org.apache.commons:commons-lang3"
    implementation "org.springframework.boot:spring-boot-starter-web"
    implementation group: 'com.oracle.database.jdbc', name: 'ojdbc8', version: '21.1.0.0'
    implementation group: 'commons-io', name: 'commons-io', version: '2.8.0'
    implementation 'org.apache.commons:commons-csv:1.8'
    implementation group: 'org.apache.any23', name: 'apache-any23-encoding', version: '2.4'
    implementation group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.8.0'
    implementation group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity4', version: '3.0.4.RELEASE'
    implementation group: 'org.springframework.boot', name: 'spring-boot', version: '1.5.22.RELEASE'

    providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
    testImplementation("org.springframework.boot:spring-boot-starter-test")
    testImplementation("org.springframework.security:spring-security-test")
    testImplementation group: 'junit', name: 'junit', version: '4.12'
    testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.7.0'
}

However, when I tried to launch the project... and it failed. All I could see in IntelliJ was the error saying "CPR:failed". Refreshing Gradle itself and "Invalidate caches / Restart" in IntelliJ both didn't work as well.

enter image description here

In project's classes each import is inactive (seems like dependencies are not visible) and it can not recognize Spring's annotations.
Gradle tab in IntelliJ is empty - there is no any profile in it.
In Gradle's settings I chose: "Use Gradle from: specified location" (gradle-6.7.1. directory).

The most annoying thing about it, is that Gradle doesn't throw any error at all!

Do you guys have any idea about what could be a possible issue here? Maybe it's something about integration Gradle with IntelliJ?

Thank you in advance for any piece of help here!

Kind regards, Mateusz

EDIT: It looks like a Java version could have some impact on the Gradle's work, as after I changed it from 8 to 15, I started to get a more detailed error in the console:

Unable to load class 'org.jetbrains.kotlin.noarg.ide.NoArgModel'.

Possible causes for this unexpected error include:

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network)

The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart)

Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
question from:https://stackoverflow.com/questions/65944582/gradle-builds-successfully-spring-boot-project-but-the-launching-on-local-host

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...