MIssing dependency on demo (https://spring.io/quickstart)? - spring

Executing the steps described here --> https://spring.io/quickstart with gradle
(maven works not becuase of complaining about the jdk version)
The exmaple works only if i add the following line to the dependency:
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.3.4.RELEASE'
I start it with
/usr/local/gradle-6.3/bin/gradle bootRun
I can't believe that the demo is wrong,
but i also don't see what i missed.
Complete build file is -->
plugins {
id 'org.springframework.boot' version '2.3.4.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
}
group = 'org.schaffa'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation('org.springframework.boot:spring-boot-starter-test')
{
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.3.4.RELEASE'
}
test {
useJUnitPlatform()
}

Related

How to resolve invalid packaging for parent POM, must be "pom" but is "jar"

To resolve spring-framework vulnerability posted by spring.io
I tried upgrading spring-boot version from 2.4.5 to 2.5.12 and with gradle-6.8 version, on running ./gradlew clean build task is failing with error
Invalid packaging for parent POM org.apache.logging.log4j:log4j-api:2.17.2, must be "pom" but is "jar" in org.apache.logging.log4j:log4j-api:2.17.2
The dependency org.springframework.boot:spring-boot-starter-webflux loads the internal dependency log4j-api:2.17.2
How to resolve invalid parent POM packaging for internal dependencies?
build.gradle
buildscript {
ext {
springBootVersion = '2.5.12'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
{
exclude group: 'org.slf4j', module: 'slf4j-ext'
}
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.service'
version = ''
sourceCompatibility = 11
def logbackVersion = '1.2.3'
repositories {
mavenCentral()
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.apache.logging.log4j') {
details.useVersion '2.17.1'
}
}
}
dependencies {
implementation ('org.springframework.boot:spring-boot-starter-webflux')
developmentOnly('org.springframework.boot:spring-boot-devtools')
testImplementation('org.springframework.boot:spring-boot-starter-test')
testImplementation('io.projectreactor:reactor-test')
implementation("ch.qos.logback:logback-core:${logbackVersion}")
implementation("ch.qos.logback:logback-classic:${logbackVersion}")
implementation('org.apache.httpcomponents:httpclient:4.5.11')
implementation('org.apache.commons:commons-collections4:4.4')
implementation("org.springframework.cloud:spring-cloud-vault-config:2.1.3.RELEASE")
implementation("org.springframework.cloud:spring-cloud-vault-config-consul:2.1.3.RELEASE")
implementation group: 'org.springframework.cloud', name: 'spring-cloud-consul-dependencies', version: '1.0.0.RELEASE', ext: 'pom'
implementation('com.amazonaws:aws-java-sdk-sqs:1.11.634')
implementation('org.projectlombok:lombok:1.18.12')
implementation('org.yaml:snakeyaml:1.26')
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
annotationProcessor('org.projectlombok:lombok:1.18.12')
implementation group: 'org.bouncycastle', name: 'bc-fips', version: '1.0.2'
implementation group: 'org.bouncycastle', name: 'bctls-fips', version: '1.0.11'
}
Adding mavenBom spring-cloud-dependencies helped resolve this issue. Suspecting webflux pulled in a transitive dependency to an older release and adding spring-cloud-dependencies bom in dependencyManagement ensured all Spring dependencies are at the same version
Here's update build.gradle file that worked
plugins {
id 'org.springframework.boot' version '2.6.6'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'application'
}
group = 'com.service'
version = '1.0.0-SNAPSHOT'
sourceCompatibility = '11'
application {
mainClass = 'com.service.scheduler.SchedulerApplication'
}
repositories {
mavenCentral()
}
ext {
set('springCloudVersion', "2021.0.1")
set('logbackVersion', "1.2.11")
}
bootJar {
archiveFileName = 'scheduler.jar'
}
bootRun {
systemProperties = System.properties
}
dependencies {
/*---spring dependencies---*/
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.cloud:spring-cloud-starter-vault-config'
implementation 'org.springframework.cloud:spring-cloud-vault-config-consul'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
implementation 'com.amazonaws:aws-java-sdk-sqs:1.12.187'
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
implementation 'org.apache.commons:commons-collections4:4.4'
implementation 'org.yaml:snakeyaml:1.30'
implementation 'com.google.code.gson:gson:2.9.0'
/*---fips dependencies---*/
implementation group: 'org.bouncycastle', name: 'bc-fips', version: '1.0.2'
implementation group: 'org.bouncycastle', name: 'bctls-fips', version: '1.0.11'
/*---lombok dependencies---*/
implementation 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
/*---logback dependencies---*/
implementation("ch.qos.logback:logback-core:${logbackVersion}")
implementation("ch.qos.logback:logback-classic:${logbackVersion}")
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

Repositories in gradle project were not indexed

I'm trying to synchronize a gradle project with some dependences to Spring Boot and Maven, but there is an error that indicates the following repositories used in the project are not indexed yet:
Unindexed remote maven repositories found.
The following repositories used in your gradle projects were not
indexed yet:
http://repo.spring.io/milestone
http://repo.spring.io/snapshot
https://repo1.maven.org/maven2
https://plugins.gradle.org/m2
If you want to use dependency completion for these repositories
artifacts, Open Repositories List, select required repositories and press "Update" button.
Then I'm trying to update the remote repositories manually, but I'm getting an error while I trying to do.
Any know what can I do to resolve the issue?
I'm using IntelliJ IDEA 2017.1.6 and the gradle version is 2.2, I leave the build.gradle file of the project with the dependencies that I use.
group 'com.scl.boot'
version '0.5'
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'war'
apply plugin: 'spring-boot'
apply plugin: 'org.sonarqube'
apply plugin: 'com.bmuschko.cargo'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
buildscript {
repositories {
jcenter()
maven { url 'http://repo.spring.io/snapshot' }
maven { url 'http://repo.spring.io/milestone' }
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.2.7.RELEASE'
classpath 'org.sonarqube.gradle:gradle-sonarqube-plugin:1.1'
classpath 'com.bmuschko:gradle-cargo-plugin:2.2.1'
}
}
repositories {
maven { url 'http://repo.spring.io/snapshot' }
maven { url 'http://repo.spring.io/milestone' }
mavenCentral()
jcenter()
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-aop'
compile 'org.springframework.boot:spring-boot-starter-logging'
compile 'org.springframework.boot:spring-boot-starter-security'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-rest', version: '1.3.6.RELEASE'
compile 'org.jsondoc:spring-boot-starter-jsondoc:1.2.9'
compile 'org.jsondoc:jsondoc-ui-webjar:1.2.9'
compile 'org.springframework:spring-jdbc'
compile 'org.springframework.data:spring-data-oracle:1.2.1.RELEASE'
compile group: 'cn.easyproject', name: 'ojdbc7', version: '12.1.0.2.0'
compile group: 'org.springframework.data', name: 'spring-data-jdbc-core', version: '1.2.1.RELEASE'
compile 'org.apache.tomcat:tomcat-dbcp:8.0.28'
compile 'org.slf4j:slf4j-api:1.7.+'
compile 'org.op4j:op4j-jodatime:1.1'
compile 'org.springframework.boot:spring-boot-devtools:1.3.0.M2'
compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
compile 'org.json:json:20151123'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'org.codehaus.groovy:groovy-all'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.3'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.3'
compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-xml', version: '2.8.3'
cargo 'org.jboss.as:jboss-as-controller-client:7.2.0.Final'
compile group: 'org.codehaus.cargo', name: 'cargo-core-uberjar', version: '1.5.0'
cargo 'org.codehaus.cargo:cargo-ant:1.4.16'
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile 'org.springframework.boot:spring-boot-starter-test:1.2.7.RELEASE'
testCompile group: 'org.spockframework', name: 'spock-core', version: '1.0-groovy-2.4'
}
war {
archiveName = "CyCRest.war"
configurations {
runtime.exclude module: 'spring-boot-starter-tomcat'
runtime.exclude module: 'spring-boot-starter-logging'
}
}
[EDIT] This is the idea.log file with the exceptions that I'm getting:
java.io.IOException: Transfer for nexus-maven-repository-index.gz
failed
Download the log file.

Gradle spring-boot error - java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication

Below is my build.gradle file. I am using java 11 and IntelliJ 2019.2.2. As I run the application, I get: Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
As such the error or problem appears to be the same as the one you get when you upgrade from gradle version 2.x to anything 3.4 onwards, but I should not be getting the error with any recent IntelliJ version. I have cleaned the repository, idea cache etc. The main class (com.itreatmd.emr.Application) has only one line - SpringApplication.run(Application.class, args) and that throws this exception.
Also, when I build the tar file from command line and then explode the tar file, I do not see my jar file packaged under the lib folder of the tar file. I am clearly missing something, presumably something obvious, but just cannot get the handle to it.
buildscript {
ext {
springBootVersion = '2.2.1.RELEASE'
}
repositories {
jcenter()
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/milestone" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
}
}
plugins {
id 'org.springframework.boot' version '2.2.1.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
id 'application'
id 'idea'
}
mainClassName = 'com.itreatmd.emr.Application'
group = 'com.itreatmd.emr'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
targetCompatibility = 1.8
repositories {
mavenCentral()
}
jar {
baseName = 'emrServices'
version = '1.0-SNAPSHOT'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-jersey'
compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
compile group: 'commons-codec', name: 'commons-codec', version: '1.5'
compile group: 'commons-io', name: 'commons-io', version: '2.6'
compile group: 'org.json', name: 'json', version: '20180813'
compile "org.apache.httpcomponents:httpmime:4.2.3"
compile group: 'org.yaml', name: 'snakeyaml', version: '1.8'
compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.3.1'
compile group: 'org.springframework', name: 'spring-webmvc', version: '3.1.1.RELEASE'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
jar {
manifest {
attributes 'Main-Class': 'com.itreatmd.emr.Application',
'Class-Path': configurations.runtime.files.collect { "lib/$it.name" }.join(' ')
}
}
i am using spring boot 2.2.5 and gradle 5.1.2.
run gradle build -x test, it will tell you what error it is.
in my case, it told me that error: package org.jasig.cas.client.authentication does not exist, but this package exists in fact.
then i remembered that i added a dependency runtimeOnly 'org.apereo.cas:cas-server-support-validation:5.3.15.1'
after comment this dependency, my project can start success.

after gradle build success, class not found exception while running spring boot application

I have created spring boot application using Gradle but after successfully building the application when I am trying to run the application it gives me the main class not found an exception.
I am building an application using the below command:
.\gradlew clean build
The build is getting success. But when I try to run the application as a spring boot application then I am getting the error.
Error: Could not find or load main class com.abc.ccs.CommunityApplication
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootjar {
baseName = 'create-community'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
runtimeOnly 'org.postgresql:postgresql'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: '1.5.2.RELEASE'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.26'
compile group: 'org.codehaus.janino', name: 'janino', version: '3.0.6'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
}
jar {
manifest {
attributes(
"Main-Class": "com.abc.ccs.CommunityApplication"
)
}
}

Gradle plugin cannot be found in a SpringBoot Application

I have a multi-module setup and when I try to refresh the gradle tasks I see the following error:
Plugin [id: 'org.springframework.boot', artifact: 'org.springframework.boot:spring-boot-gradle-plugin:null'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.springframework.boot:spring-boot-gradle-plugin:null')
Searched in the following repositories:
maven(https://repo.spring.io/snapshot)
maven2(https://repo.spring.io/milestone)
Gradle Central Plugin Repository
Open File
I recently added a new module and ever since I added the module I can see this error; though I have deleted that module the error just does not go away. My build.gradle for the main package looks like this :
plugins {
id 'org.springframework.boot' version '2.1.4.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
group = 'com.pro.review'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'
runtimeOnly 'org.postgresql:postgresql'
}
dependencies {
compile project(':libs')
compile project(':subscription-manager')
}

Resources