I'm trying to set up a nested multi module project with gradle.
I have the following structure:
stock-client-root
|-- settings.gradle
|-- build.gradle
|-- stock-client
| |-- build.gradle
|-- stock-ui
|-- build.gradle
The problem is, that I cannot import any dependencies that are declared in the build.gradle files except spring boot related things.
Example: I want to use javafx. I declared it in the stock-ui/build.gradle file but when I want to import it in the module, intelliJ tells me, it cannot resolve that dependency.
I tried almost everything to solve this:
Reload the project via gradle
Restart the IDE
Invalidate cache + rebuild project
Created a new project with that structure and tried it again
Can anyone point out, where the problem might be?
And here is the content of the files:
stock-client-root/settings.gradle
rootProject.name = 'stock-client-root'
include 'stock-client'
include 'stock-ui'
stock-client-root/build.gradle
subprojects {
apply plugin: 'java'
group = 'com.demo'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
}
stock-client/build.gradle
plugins {
id 'org.springframework.boot' version '2.4.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.demo'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-webflux'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
}
test {
useJUnitPlatform()
}
stock-ui/build.gradle
plugins {
id 'org.springframework.boot' version '2.4.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.demo'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation group: 'org.openjfx', name: 'javafx-graphics', version: '13.0.1'
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
useJUnitPlatform()
}
Related
I am trying to use springdoc-openapi-ui using gradle dependency.
Maven
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.4.3</version>
</dependency>
Gradle
plugins {
id 'org.springframework.boot' version '2.3.1.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group = 'fete.bird'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '14'
compileJava {
options.compilerArgs += ["--enable-preview"]
}
repositories {
jcenter()
mavenCentral()
}
ext {
set('springCloudVersion', "Hoxton.SR6")
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
implementation 'org.springdoc:springdoc-openapi-ui'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.kafka:spring-kafka'
implementation 'org.projectlombok:lombok'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
test {
useJUnitPlatform()
}
Error
Could not find org.springdoc:springdoc-openapi-ui:.
Required by:
project :
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
What is the repository for the gradle?
Try adding the library with latest version in your project
implementation("org.springdoc:springdoc-openapi-ui:1.4.6")
implementation 'org.springdoc:springdoc-openapi-ui' fail with following error Could not find org.springdoc:springdoc-openapi-ui
While following worked
implementation 'org.springdoc:springdoc-openapi-ui:1.6.6'
I am using apollo graphql client in java code. My gradle file is
plugins {
id 'org.springframework.boot' version '2.2.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
maven {
url 'http://dl.bintray.com/apollographql/android'
}
}
dependencies {
implementation "com.apollographql.apollo:apollo-android-support:1.0.0"
implementation "com.apollographql.apollo:apollo-runtime:1.0.0"
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
I have followed the docs mentioned in https://github.com/apollographql/apollo-android
I got stuck at step 4 and 5.
Not able to add
generateKotlinModels.set(false)
}
in gradle file and while executing the command
gradlew generateApollo its getting error as
Task 'generateApolloSources' not found in root project 'testProject'
Could anyone please help
You will need to apply the Apollo plugin:
plugins {
id 'org.springframework.boot' version '2.2.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
id 'com.apollographql.apollo' version '2.1.0'
}
You should also bump the Apollo dependencies to '2.1.0' as '1.0.0' is pretty old.
I am facing following issue while building spring boot project with gradle
What went wrong:
A problem occurred evaluating settings 'ConfigurationManager'.
Could not find method pluginManagement() for arguments [settings_4czoxeapfgxghi54ogzhrlgs9$_run_closure1#6e5e4ee] on settings 'ConfigurationManager' of type org.gradle.initialization.DefaultSettings.
Content of settings.gradle is as follows
pluginManagement {
repositories {
gradlePluginPortal()
}
}
rootProject.name = 'ConfigurationManager'
Content of gradle-wrapper.properties is as follows
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Content of build.gradle is as follows
plugins {
id 'org.springframework.boot' version '2.1.6.RELEASE'
id 'java'
id 'war'
}
apply plugin: 'io.spring.dependency-management'
group = 'demo.comp.dept'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-ldap'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}
i am spring boot using gradle build. till yesterday gradle build was run smoothly. But today i got this following error ;
Could not resolve all artifacts for configuration ':classpath'.
Could not find spring-core.jar (org.springframework:spring-core:5.2.0.BUILD-SNAPSHOT:20190328.215418-203).
Searched in the following locations:
https://repo.spring.io/snapshot/org/springframework/spring-core/5.2.0.BUILD-SNAPSHOT/spring-core-5.2.0.BUILD-20190327.205120-195.jar
Could not find spring-jcl.jar (org.springframework:spring-jcl:5.2.0.BUILD-SNAPSHOT:20190328.215418-203).
Searched in the following locations:
https://repo.spring.io/snapshot/org/springframework/spring-jcl/5.2.0.BUILD-SNAPSHOT/spring-jcl-5.2.0.BUILD-20190327.205120-195.jar
this is my build.gradle file
buildscript {
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/snapshot' }
maven { url 'https://repo.spring.io/milestone' }
maven {url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.3.RELEASE")
}
}
plugins {
id 'org.springframework.boot' version '2.2.0.BUILD-SNAPSHOT'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'idea'
group = 'me.namila'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/snapshot' }
maven { url 'https://repo.spring.io/milestone' }
jcenter()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
When visiting the relevant url,what i can see is gradle is searching for 27th march build (spring-jcl-5.2.0.BUILD-20190327.205120-195.jar) while the server has the 28th build spring-jcl-5.2.0.BUILD-20190328.164750-201.jar. how to fix this error? i have added buildscript repositories too. any suggesions?
As Antoniossss said in the comments, this happened because snapshot build failure. To fix it i moved to previous build version of springboot. i did the following changes to the build.gradle file;
id 'org.springframework.boot' version '2.1.3.RELEASE'
changed the '2.2.0.BUILD-SNAPSHOT' to 2.1.3 release. this fixed the error. :)
the buildscript repositories & dependencies are a mess, there's a mismatch:
buildscript {
repositories {
maven { url 'https://repo.spring.io/libs-milestone' }
}
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.2.0.BUILD-SNAPSHOT'
}
}
apply plugin: 'org.springframework.boot'
see the documentation.
I have a Gradle project in IntelliJ which I am using to control my dependencies but I am new to Gradle so I am probably doing something wrong.
I am getting this error when running my code:
java.sql.SQLException: No suitable driver found for jdbc:mariadb://<db address>
the build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.10.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.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('org.springframework.boot:spring-boot-starter-test')
}
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
dependencies {
// https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client
compile group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '1.1.7'
}
The jdbc.properties file that I am also using:
jdbc.drivers=com.mariadb.jdbc.Driver
jdbc.url=jdbc:mariadb://<db address>
jdbc.user=root
jdbc.password=password
What am I doing wrong?
You are missing a dependency on the MariaDB Java driver hence this message:
java.sql.SQLException: No suitable driver found for jdbc:mariadb://<db address>
You can add the MariaDB Java driver to your classpath by updating the dependencies block of build.gradle ...
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.mariadb.jdbc:mariadb-java-client")
testCompile('org.springframework.boot:spring-boot-starter-test')
}