I have a spring-boot app that I was able to start up the server in eclipse.
However, when I goto terminal and do gradle compile, here is the console log i am getting:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'springBootREST'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE.
Required by:
:springBootREST:unspecified
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE.
> Could not get resource 'https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/1.2.5.RELEASE/spring-boot-gradle-plugin-1.2.5.RELEASE.pom'.
> Could not HEAD 'https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/1.2.5.RELEASE/spring-boot-gradle-plugin-1.2.5.RELEASE.pom'.
> repo1.maven.org: unknown error
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
I am not entirely sure why this is happening: it seems like it is having some issues with proxy server, but if I were to do wget I can get the files under repo1.maven...
For reference, this is my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
}
}
// same as what is in my .bash_profile
systemProp.http.proxyHost='my proxy server'
systemProp.http.proxyPort='my proxy port'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'spring-boot'
group = 'lookupGroup'
jar {
baseName = 'lookupService'
version = '0.1.0'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile 'org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE'
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("junit:junit")
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
Any idea why I can't build?
Proxy properties should be configured in gradle.properties file as stated in the docs.
Related
error msg
FAILURE: Build failed with an exception.
* What went wrong:
Cannot locate tasks that match 'demo:test' as project 'demo' not found in root project 'demo'.
* Try:
> Run gradlew projects to get a list of available projects.
> 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
plugins {
id 'java'
id 'org.springframework.boot' version '2.7.8'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
spring boot 2.7.8.
java spring quick start guide
I'm unsure how to do this. Can anyone help my troubleshoot this problem? Thanks!
I have very simple java project, and I'm using gradle to build it.
And I have Linux RedHat server (without access to internet) but this server has access to internal nexus repository where all required dependencies present.
This is build.gradle file:
buildscript {
ext {
springBootVersion = '2.0.3.RELEASE'
}
repositories {
maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id 'com.github.jacobono.jaxb' version '1.3.5' // this is 14 line
}
repositories {
maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
}
subprojects {
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = 1.8
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
}
}
buildscript {
repositories {
maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
}
}
repositories {
maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
}
}
allprojects {
buildscript {
repositories {
maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
}
}
}
Settings file settings.gradle:
include 'api'
project(":api").name = "api"
And this project has 1 submodule api filder.
api build.gradle file:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.github.jacobono.jaxb'
springBoot {
buildInfo()
}
group = 'com.example'
version = '1.0.0'
sourceCompatibility = 1.8
repositories {
maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
}
springBoot {
mainClassName = 'com.example.TestApplication'
}
On my linux server I have:
- java 8
- gradle 4.5.1
- mvn 3.5.6
When I'm running gradle clean inside root folder of my project, after 5-10 mins I'm receiving error:
FAILURE: Build failed with an exception.
* Where:
Build file '/my-proj/build.gradle' line: 14
* What went wrong:
Plugin [id: 'com.github.jacobono.jaxb', version: '1.3.5'] 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 'com.github.jacobono.jaxb:com.github.jacobono.jaxb.gradle.plugin:1.3.5')
Searched in the following repositories:
Gradle Central Plugin Repository
* 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 FAILED in 10m 3s
And for some reason in this error there is no information about my nexus repository...I assuming that it even haven't tried this repository. And the question is why...?
I would be very happy of any help...maybe I made mistake in build.gradle file somewhere...
p.s. on my local pc(I have access to internet and to this repository everything works file)
Plugins by default resolved from Gradle Plugin Portal. If you want to resolve them from different sources, You should add configuration to settings.gradle file.
Example:
pluginManagement {
repositories {
maven {
url '../maven-repo'
}
gradlePluginPortal()
ivy {
url '../ivy-repo'
}
}
}
Check the docs for details.
I want to add the tomcat plugin to my gradle build, but the plugin cannot be found , gradle shows the error
Plugin with id 'com.bmuschko.tomcat' not found.
I followed the steps on the github page of this plugin, but it does not work.
In my project I have general build.gradle in this I am loading my project.gradle in this I defined the tomcat-plugin configuration.
build.gradle
apply plugin: 'java'
apply plugin: 'maven'
sourceCompatibility = 1.8
ext {
debug = false
}
apply from: 'project.gradle'
group = myGroup
version = myVersion + '-SNAPSHOT'
project.gradle
//https://github.com/bmuschko/gradle-tomcat-plugin
buildscript {
repositories {
jcenter();
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.4.2'
}
}
apply plugin: "com.bmuschko.tomcat"
apply plugin: "idea"
apply plugin: "project-report"
apply plugin: "war"
I can ensure that dependencies can be resolved from my machine, because other gradle projects work, so that it should not be a network issue, there is no proxy configuration etc.
You have to put buildscript{} into your main build.gradle. The buildscript process is outside the regular Gradle build. Same applies to plugins{} as well (since they are equivalent.)
So if you put
buildscript {
repositories {
jcenter();
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.4.2'
}
}
into your build.gradle, it would work.
[Update]
I have created a sample gradle project with the fix in it.
And the TravisCI build is here.
Or you may try using the plugin type:
apply plugin: com.bmuschko.gradle.tomcat.TomcatPlugin
instead of
apply plugin: "com.bmuschko.tomcat"
in your project.gradle file.
This is my build.gradle file
buildscript {
ext {
springBootVersion = '1.4.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'yBayApplication'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
springBoot {
mainClass = "com.ybayApplication.customerAccount.CustomerServiceApplication"
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-eureka-server:1.2.3.RELEASE')
compile('org.springframework.cloud:spring-cloud-starter-zuul')
compile group: 'com.netflix.zuul', name: 'zuul-core', version: '2.0.0-rc.1'
compile group: 'com.netflix.governator', name: 'governator-archaius', version: '1.6.0'
compile group: 'io.reactivex', name: 'rxjava-string', version: '0.22.0'
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("com.h2database:h2")
testCompile("junit:junit")
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.BUILD-SNAPSHOT"
}
}
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.8'
}
}
And this is the error message, I am receiving while building the gradle.
Gradle Distribution: Local installation at C:\gradle\gradle-3.4.1
Gradle Version: 3.4.1
Java Home: C:\Program Files (x86)\Java\jdk1.8.0_121
JVM Arguments: None
Program Arguments: None
Gradle Tasks: clean build
:clean UP-TO-DATE
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':detachedConfiguration5'.
> Could not find com.netflix.governator:governator-archaius:1.6.0.
Searched in the following locations:
https://repo1.maven.org/maven2/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.pom
https://repo1.maven.org/maven2/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.jar
https://repo.spring.io/snapshot/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.pom
https://repo.spring.io/snapshot/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.jar
https://repo.spring.io/milestone/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.pom
https://repo.spring.io/milestone/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.jar
Required by:
project :
project : > com.netflix.zuul:zuul-core:2.0.0-rc.1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.77 secs
As you can see in the build.gradle file, I have added the missing dependency as well. I am tying to implement a Zuul filter based on this example in gradle https://spring.io/guides/gs/routing-and-filtering/.
On the first look, it looks like you need to remove the
compile group: 'com.netflix.zuul', name: 'zuul-core', version: '2.0.0-rc.1'
The compile('org.springframework.cloud:spring-cloud-starter-zuul') is dependent on zuul core so it will download it.
Additionally, for the governator-archaius I don't see the version 1.6.0.
I think you meant 1.16.0. Look at the link here to grab the accurate version https://mvnrepository.com/artifact/com.netflix.governator/governator-archaius
Let me know if this solves your problem.
I am attempting to work through the Spring Framework Restful Web Service creation tutorial(https://spring.io/guides/gs/rest-service/#scratch) using Gradle and IntelliJ. I have followed everything to the letter but being fairly new to Spring, IntelliJ, and Java in general I'm unsure how to go about further debugging my issue.
When I attempt to build my project I receive a few errors stating "Java: package org.springframework.web.bind.annotation does not exist." I'm guessing I'm missing a library reference but am unsure how to check and include it.
buildscript {
ext {
springBootVersion = '1.3.5.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.springframework:spring-web:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'hello_springtest'
version = '0.0.1-SNAPSHOT'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
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.8'
}
}
Just thought I'd add some additional information. I'm still seeing the errors and am unsure why but my project does report that the build was successful. When I attempt to make the project however that's when I receive the annotation does not exist error.
You have some dependency in your builds script, which seems to me redundant and causes Gradle to look up for additional dependencies.
Just remove this dependency from your buildscript dependencies
classpath("org.springframework:spring-web:${springBootVersion}")
I see no reason to use it within your buildscript.