I created clean project with spring boot initializer and I get configure build error. The message I get is: Could not find org.junit:junit-bom:5.4.0-SNAPSHOT. but in my gradle file I don't have it. What's wrong with it?
buildscript {
ext {
springBootVersion = '2.2.0.BUILD-SNAPSHOT'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 11
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
implementation('org.springframework.boot:spring-boot-starter-security')
implementation('org.springframework.boot:spring-boot-starter-web')
testImplementation('org.springframework.boot:spring-boot-starter-test')
testImplementation('org.springframework.security:spring-security-test')
}
You're using a development (snapshot) version of Spring Boot that refers to a development (snapshot) version of JUnit 5, but you have not added JUnit's snapshot repository: https://oss.sonatype.org/content/repositories/snapshots/org/junit/junit-bom/5.4.0-SNAPSHOT/:
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
But you'd better use generally available versions.
The Junit dependency comes with "spring-boot-starter-test", it may not be available in your spring version. Try to change the spring version or use a latest version and give it a go.
Related
I am creating a spring boot application with the following properties the project is running successfully when I run projects with Gradle bootrun it is running successfully but when i create a jar and deploy its not working here is my build.gradle
I have checked all the versions of my project are same.
Error :Error mapping to ad-hoc class .. At present, only #Result types that are discovered by the domain entity package scanning can be mapped.;
nested exception is org.neo4j.ogm.exception.core.MappingException: Error mapping to ad-hoc class com.vipul.... At present, only #Result types that are discovered by the domain entity package scanning can be mapped
PS: I KNOW ABOUT QUERY RESULT mapping but its working with bootRun but not with bootJar
buildscript {
ext {
springBootVersion = '2.0.5.RELEASE'
swaggerVersion = '2.5.0'
jacksonVersion = '2.9.2'
projectVersion = "0.0.1"
version = "0.0.1"
}
repositories {
mavenCentral()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: "io.spring.dependency-management"
apply plugin: 'idea'
apply plugin: 'application'
version = "$projectVersion-SNAPSHOT"
sourceCompatibility = 1.8
mainClassName = 'com.vipul.Application'
applicationDefaultJvmArgs = ["-Xdiag"]
repositories {
mavenCentral()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
maven{ url "https://repo.spring.io/plugins-release"}
}
task wrapper(type: Wrapper) { gradleVersion = '4.4' }
ext {
springCloudVersion = 'Finchley.RELEASE'
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-aop')
compile('org.springframework.boot:spring-boot-starter-cache')
compile('org.springframework.boot:spring-boot-starter-data-neo4j')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
Try changing springBoot and springCloud versions in your build.gradle
**
springBootVersion='2.0.0.RELEASE'
**
It seems to be problem with spring boot version. springBootVersion = '2.0.5.RELEASE'
I have multiproject gradle configuration. I'd like to sign my artifacts before publishing. I do the following:
allprojects {
apply plugin: 'java'
sourceCompatibility = 1.10
}
subprojects {
group 'com.example'
version '1.0.0'
apply plugin: 'maven-publish'
apply plugin: 'signing'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
...
}
test {
useJUnitPlatform()
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
mavenLocal()
}
}
signing {
sign publishing.publications.mavenJava
}
}
I get the following error:
Cannot configure the 'publishing' extension after it has been
accessed.
I have no idea what does it mean. I use gradle 4.8.
I have 3 subprojects there.
I ran into the same issue with Gradle 4.9
Apply the signing plugin before the maven-publish.
Hope it helps.
apply plugin: 'signing'
apply plugin: 'maven-publish'
I would like the maven equivalent of properties in gradle:
<properties>
<spring-batch.version>4.0.0.M2</spring-batch.version>
</properties>
When I added ext['spring-batch.version'] = '4.0.0.M2' in build.gradle, imports are not working.
buildscript {
ext {
springBootVersion = '1.5.4.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
ext['spring-batch.version'] = '4.0.0.M2'
dependencies {
compile('org.springframework.boot:spring-boot-starter-batch')
compile("org.hsqldb:hsqldb")
}
I also tried to add spring-batch.version=4.0.0.M2 in gradle.properties, but not working also.
It's failing because 4.0.0.M2 isn't in Maven central.
To fix it, add the Spring milestone Maven repository:
repositories {
mavenCentral()
maven {
url "http://repo.spring.io/libs-milestone"
}
}
first I'd use the new plugin mechanis like so:
buildscript {
repositories { mavenCentral() }
}
plugins {
id 'java'
id 'application' // for docker needed the main class in jar manifest
id 'eclipse'
id 'idea'
id 'org.springframework.boot' version '1.5.4.RELEASE' // automagically includes io.spring.dependency-management
}
this should automagically give you the correct version of all org.springframework.boot dependencies, without having to specify them explicitly (so no need to give a version number for spring-batch.
if you'd like to define further project.ext properties, do so like:
ext {
group = 'minimal_cloud_stream_producer'
groupId = 'de.demo'
baseName = 'minimal_cloud_stream_producer'
port = 8080
}
maybe you have to add a dependencyManagement section too, like so
dependencyManagement {
imports {
mavenBom 'org.springframework.boot:spring-boot-starter-parent:1.5.4.RELEASE'
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.SR1'
}
}
When I build a project in console I have no service of type styled text output factory available in project scope service. I have also a file pom.xml .I don't know what I do it wrong
This is my build.gradle :
import java.sql.Wrapper
buildscript {
ext {
springBootVersion = '1.2.5.RELEASE'
}
repositories {
maven { url "http://repo.spring.io/libs-milestone" }
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("io.spring.gradle:dependency-management-plugin:0.5.1.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
war {
baseName = 'springboot'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-milestone" }
}
configurations {
providedRuntime
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("javax.servlet:jstl:1.2")
runtime("mysql:mysql-connector-java")
compile("org.springframework.boot:spring-boot-starter-jdbc")
// https://mvnrepository.com/artifact/javax.el/el-api
compile group: 'javax.el', name: 'el-api', version: '2.2.1-b04'
compile ("org.springframework.boot:spring-boot-starter-web")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
providedRuntime 'org.apache.tomcat.embed:tomcat-embed-jasper'
}
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
I believe the problem is a function of the versions of Gradle and Spring's dependency-management-plugin that are in use.
See the original report from the Spring guys in this Bug in Gradle 2.14-rc1 - No service of type StyledTextOutputFactory report. Gradle moved the StyledTextOutputFactory to an internal package at some point (for the 3.0 release), which broke dependency-management-plugin 0.5.x.
This dependency-management-plugin issue details their making changes to address this in their 0.6.0 release.
I see your build script references Gradle 2.3...but I'm wondering if that is accurate.
I think it boils down to either use Gradle 2.x with dependency-management-plugin 0.5.x or use Gradle 3.x with dependency-management-plugin 0.6.x.
Good luck.
I am new to gradle.
I am building a project using gradle.
It build successfully without any error. While running the build jar file it is giving classNotFoundException.
I am building a simple spring project from spring.io
However question look similar to this but, could not find a solution. Please help.
edit: This is how my build.gradle looks
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'gs-rest-service'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("junit:junit")
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
startScripts {
mainClassName = 'Application'
}
springBoot {
mainClass = "Application"
}
You'll need to start the application with the generated start scripts. They will automatically take care of setting up the proper classpath.