Converting gradle-java to springboot - java

I need to convert this gradle-java (gradle 6.3, java 8, camel 3.4.2),
plugins {
id 'java-library'
}
repositories {
jcenter()
}
dependencies {
compile group: 'org.apache.camel', name: 'camel-rest', version: '3.4.2'
}
To this (gradle 7.3.3, java 8, camel 3.14.3 springboot 2.7.0),
plugins {
id 'java-library'
id 'org.springframework.boot' version '2.7.0'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'war'
}
repositories {
mavenCentral()
}
targetCompatibility = '1.8'
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.apache.camel:camel-rest::3.14.3'
}
But I get this error,
What went wrong:
Execution failed for task ':compileJava'.
Could not resolve all files for configuration ':compileClasspath'.
Could not find org.apache.camel:camel-rest:.
Required by:
What should I do?
Thanks
Ric

The double colon,
:camel-rest::3.14.3'

Related

Adding Module dependency Gradle

I am trying to add the dependency for a multimodule gradle project
The parent Module is -MicroOne.
Child modules are-controller, service
Build.gradle of MicroOne is
group = 'com.test'
Settings.gradle of MicroOne is
rootProject.name = 'microone'
include 'service'
include 'controller'
Build.gradle for the service module is
plugins {
id 'org.springframework.boot' version '2.5.1'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group ='com.test'
version= '0.0.1-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
implementation project (':controller')
implementation 'org.springframework.boot:spring-boot-starter-web'
}
And for Controller is
plugins {
id 'org.springframework.boot' version '2.5.1'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group 'com.test'
version '0.0.1-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
}
test {
useJUnitPlatform()
}
I am not able to add the dependency from Service module to the Controller module, I am not able to import a class which is present in the Service module to the Controller module

Spring Boot can't find LdapAuthenticationProviderConfigurer and OAuth2LoginConfigurer classes

This is the error I am getting when I try to debug the application or run it with coverage.
[2020.11.20 11:59:34] (Coverage): Error during class instrumentation: org.springframework.security.config.annotation.authentication.configurers.ldap.LdapAuthenticationProviderConfigurer: java.lang.RuntimeException: java.io.IOException: Class not found
[2020.11.20 11:59:34] (Coverage): Error during class instrumentation: org.springframework.security.config.annotation.web.configurers.oauth2.client.OAuth2LoginConfigurer: java.lang.RuntimeException: java.io.IOException: Class not found
I think that I might be missing a dependency but I have not been able to find a suitable one.
This is my build.gradle file.
plugins {
id 'org.springframework.boot' version '2.3.3.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
id 'org.sonarqube' version '3.0'
}
group = 'com.tripsay'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.security:spring-security-test'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
compile "mysql:mysql-connector-java:5.1.49"
}
test {
useJUnitPlatform()
}

Facing issue while running gradle clean build

I am using Gradle 5 as my build tool for my Java application. I am getting below error while running gradle clean build.
Could not set unknown property 'stopPort' for root project '1-SimpleServlet' of type org.gradle.api.Project
PFA error image
Please find build.gradle file
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'jetty'
stopPort = 8081
stopKey = 'stopKey'
repositories {
mavenCentral()
}
dependencies {
providedCompile 'javax.servlet:servlet-api:2.5'
providedCompile 'org.apache.commons:commons-io:1.3.2'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
Pleas help me resolve this issue.
The jetty plugin has been deprecated with Gradle 3.0 and eventually been removed in Gradle 4.0 (Release Notes, Github Issue). Since you're using Gradle 5, I suggest to have a look at the official Building Java Web Applications guide which uses the gretty plugin.
Example build.gradle:
plugins {
id 'war'
id 'eclipse'
id 'org.gretty' version '3.0.1'
}
repositories {
mavenCentral()
}
dependencies {
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
testCompile 'junit:junit:4.12'
}

How to setup Amazon Polly SDK with Gradle in IntetlliJ

I am trying to setup AWS Polly Java SDK with Gradle in IntelliJ by following this. I have already created a simple Spring Boot application using the spring intializr, so I added the items specified in the tutorial to my build.gradle file. When try to import
import com.amazonaws.services.polly.AmazonPollyClient
IntelliJ fails to resolve name polly.
This is my full build.gradle file
buildscript {
ext {
springBootVersion = '2.0.4.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath "io.spring.gradle:dependency-management-plugin:1.0.3.RELEASE"
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'io.ai.vivid'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencyManagement {
imports {
mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.228'
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile 'com.amazonaws:aws-java-sdk-s3'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
Also IntelliJ complains that it can't resolve the name manvenBom in my build.gradle. I have already tried SO solutions to this like invalidate cache/restart but could not resolve the issue.
I used your build.gradle file to replicate the issue and was able to import AmazonPollyClient after making the following changes to the dependencies
dependencies {
compile 'com.amazonaws:aws-java-sdk-s3'
compile group: 'com.amazonaws', name: 'aws-java-sdk-polly', version: '1.11.67'
The Gradle version used 4.8

Including javafx.util.Pair as a dependency in gradle

I have a springboot app that I developed using oracle JDK and it uses the javafx.util.pair class. When the jar built is run on a system with OpenJDK it cannot find this class. How can i package this dependency with my jar? I am using gradle. Here is my build.gradle file
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.10.RELEASE")
}
}
description = "CF Service Broker using Java / Spring"
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'cf-tile'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")
compile("org.springframework.boot:spring-boot-devtools")
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('com.jayway.jsonpath:json-path')
testCompile group: 'junit', name: 'junit', version: '4.12'
}
I don't believe you can import javafx utils via gradle but you can, for platforms that do not include it in their version of OpenJDK, use openjfx.
For example you can install it in ubuntu using:
sudo apt-get install openjfx

Categories