SpringBoot FlywayCallback not present - spring-boot

I try to set up old project and it works yestarday but today I faced with strange error when try to executed application
Caused by: java.lang.TypeNotPresentException: Type org.flywaydb.core.api.callback.FlywayCallback not present
this is my build.gradle
buildscript {
ext {
springBootVersion = '2.1.1.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id "org.flywaydb.flyway" version "5.2.4"
}
flyway {
url = 'jdbc:postgresql://127.0.0.1:5434/spd_talks'
user = 'admin'
password = '111'
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.spdu'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
configurations.all {
exclude group: "commons-logging", module: "commons-logging"
}
bootJar{
archiveName = "spd_talks.jar"
}
dependencies {
implementation('org.springframework.boot:spring-boot-starter')
testImplementation('org.springframework.boot:spring-boot-starter-test')
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
compile group: 'commons-validator', name: 'commons-validator', version: '1.4.0'
compile group: 'org.flywaydb', name: 'flyway-core', version: '3.0'
testCompile group: 'com.h2database', name: 'h2', version: '1.4.197'
testCompile group: 'org.flywaydb.flyway-test-extensions', name: 'flyway-spring-test', version: '5.2.1'
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.1.2.RELEASE'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.24.0'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-websocket', version: '2.1.1.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc', version: '2.1.2.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.1.1.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '2.1.2.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version: '2.1.2.RELEASE'
compile group: 'org.springframework', name: 'spring-orm', version: '5.1.2.RELEASE'
compile group: 'org.postgresql', name: 'postgresql', version: '42.2.4'
compile group: 'postgresql', name: 'postgresql', version: '9.1-901-1.jdbc4'
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
compile group: 'log4j', name: 'log4j', version: '1.2.17'
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
compile "org.flywaydb:flyway-core:5.2.4"
compile group: 'org.springframework', name: 'spring-context', version: '5.1.4.RELEASE'
compile group: 'com.zaxxer', name: 'HikariCP', version: '3.3.0'
compile group: 'org.thymeleaf', name: 'thymeleaf', version: '3.0.11.RELEASE'
compile group: 'org.thymeleaf', name: 'thymeleaf-spring5', version: '3.0.11.RELEASE'
}
when I executed gradle build I did not faced with some error
ivan#ivan-laptop:~/hosts/java/spring_chat_jdbc_sockjs$ gradle build --refresh-dependencies --no-build-cache -x test
BUILD SUCCESSFUL in 12s
3 actionable tasks: 3 up-to-date
what happen and how to resolve it ?

Related

Gradle Multi Module Project: Apply module dependency to all subprojects except for itself

My application is a Gradle Multi Module Project, consisting of multiple services with one service-common module.
I´ve pulled all dependencies that all modules have in common out into the root build.gradle, and I also want to include the service-common module in all subprojects, which in theory works, but I´m getting a circular dependency issue because it is included in itself.
apply plugin: 'java'
group = 'com.myapplication'
ext {
set('springCloudVersion', "2.2.0.RELEASE")
set('springBootVersion', "2.2.2.RELEASE")
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
}
}
buildscript {
ext {
springBootVersion = "2.2.2.RELEASE"
}
repositories {
maven { url 'https://repo.spring.io/plugins-snapshot' }
jcenter()
mavenCentral()
}
dependencies {
classpath 'io.spring.gradle:dependency-management-plugin:1.0.7.BUILD-SNAPSHOT'
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
subprojects {
version = '1.0'
apply plugin: 'org.springframework.boot'
apply plugin: "io.spring.dependency-management"
apply plugin: 'java'
ext {
springCloudVersion = "2.2.0.RELEASE"
springBootVersion = "2.2.2.RELEASE"
}
test {
useJUnitPlatform()
}
repositories {
mavenCentral()
jcenter()
maven { url 'https://repo.spring.io/milestone' }
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter', version: "${springBootVersion}"
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: "${springBootVersion}"
compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: "${springBootVersion}"
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: "${springBootVersion}"
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc', version: "${springBootVersion}"
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: "${springBootVersion}"
compile group: 'org.springframework.boot', name: 'spring-boot-starter-logging', version: "${springBootVersion}"
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter', version: "${springCloudVersion}"
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-kubernetes', version: '1.1.1.RELEASE'
compile group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.3.2'
compile group: 'com.github.piomin', name: 'logstash-logging-spring-boot-starter', version: '1.2.2.RELEASE'
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
compileOnly 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
testCompile group: 'com.h2database', name: 'h2', version: '1.4.200'
compile group: 'org.postgresql', name: 'postgresql', version: '42.2.9'
testCompile group: 'org.springframework.cloud', name: 'spring-cloud-stream-test-support', version: "${springCloudVersion}"
implementation project(":service-common")
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
How can I exclude implementation project(":service-common") for the service-common module?
You can do something like:
subprojects {
dependencies {
if (!project.name == "service-common") {
implementation(project(":service-common"))
}
}
}

"error":"Unsupported Media Type","exception":"org.springframework.web.HttpMediaTypeNotSupportedException"

I am using spring boot 1.3.0. I want to create a rest endpoint which procduces content of type "application/hal+json".
I am getting an "Unsupported Media Type" exception. Is this mediatype in not supported in spring boot 1.3.0
Can anyone let me know in which spring boot version it is supported?
I am using Gradle.
#RequestMapping(value = Array("/grouping"), consumes = Array(MediaType.APPLICATION_JSON_VALUE), produces = Array(MediaType.APPLICATION_JSON_VALUE, "application/hal+json"), method = Array(RequestMethod.GET, RequestMethod.DELETE)) def processGroupingGetDelRequest(request: HttpServletRequest): ResponseEntity[Object] = {}
My Gradle file
dependencies {
// This is the path to where fortify is installed on the Jenkins machine. To run local swap the lines.
fortify fileTree(dir: '/opt/HP_Fortify/HP_Fortify_SCA_and_Apps_4.21/Core/lib', include: '.jar')
//fortify fileTree(dir: 'C:/Program Files/HP_Fortify/HP_Fortify_SCA_and_Apps_4.21/Core/lib/', include: '.jar')
compile group: 'org.springframework', name: 'spring-mock', version: '2.0.8'
compile group: 'org.scala-lang', name: 'scala-library', version: '2.11.7'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.3.3.RELEASE'
/* the following pulls in: spring-orm, hibernate-entity-manager, spring-data-jpa: */
compile('org.springframework.boot:spring-boot-starter-data-jpa:1.3.0.RELEASE') {
exclude group: 'org.apache.tomcat', module: 'tomcat-jdbc'
}
compile('com.zaxxer:HikariCP:2.6.1') {
exclude group: 'org.hibernate', module: 'hibernate-core'
}
/* the following pulls in: spring-jdbc, spring-tx, tomcat-jdbc: */
/* See: http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-sql.html */
/* You need a dependency on spring-jdbc for an embedded database to be auto-configured. */
/* It�s pulled in transitively via spring-boot-starter-data-jpa. */
// compile group: 'org.springframework.boot', name:'spring-boot-starter-jdbc'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '1.3.0.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-log4j2', version: '1.3.0.RELEASE'
compile group: 'org.springframework', name: 'spring-jms', version: '4.2.3.RELEASE'
compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.8.6'
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-scala_2.11', version: '2.8.6'
compile group: 'org.glassfish.jersey.core', name: 'jersey-common', version: '2.22.1'
compile group: 'org.glassfish.jersey.core', name: 'jersey-client', version: '2.22.1'
compile group: 'org.glassfish.jersey.media', name: 'jersey-media-json-jackson', version: '2.22.1'
compile group: 'org.glassfish.jersey.bundles.repackaged', name: 'jersey-guava', version: '2.22.1'
compile group: 'org.springframework.security', name: 'spring-security-ldap', version: '4.2.1.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-core', version: '4.2.1.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-config', version: '4.2.1.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-web', version: '4.2.1.RELEASE'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version:'2.8.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version:'2.8.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version:'2.8.6'
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-jaxb-annotations', version: '2.8.6'
compile group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-base', version:'2.8.6'
compile group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-json-provider', version:'2.8.6'
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-paranamer', version: '2.8.6'
// compile group: 'org.hibernate', name: 'hibernate-jpamodelgen'
// https://mvnrepository.com/artifact/com.typesafe.play/play-json_2.11
compile group: 'com.typesafe.play', name: 'play-json_2.11', version: '2.3.10'
providedCompile group: 'com.h2database', name: 'h2', version: '1.4.196'
providedCompile group: 'org.apache.activemq', name: 'activemq-broker', version: '5.12.1'
providedRuntime group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat', version: '1.3.0.RELEASE'
//Note: Un-comment if in Development the tomcat dependencies are not resolved during the spring boot runs
//providedRuntime group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '8.5.11'
scoverage 'org.scoverage:scalac-scoverage-plugin_2.11:1.1.1', 'org.scoverage:scalac-scoverage-runtime_2.11:1.1.1'
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile group: 'org.scalatest', name: 'scalatest_2.11', version: '2+'
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.10.19'
testCompile group: 'org.springframework', name: 'spring-test', version:'4.2.3.RELEASE'
testRuntime 'org.pegdown:pegdown:1.1.0'
}
My Controller class
#RequestMapping(value = Array("/grouping"), consumes = Array(MediaType.APPLICATION_JSON_VALUE), produces = Array(MediaType.APPLICATION_JSON_VALUE, "application/hal+json"), method = Array(RequestMethod.GET, RequestMethod.DELETE))
def processGroupingGetDelRequest(request: HttpServletRequest): ResponseEntity[Object] = {
val requestDetails = extractRequestInformation(request)
val response = Service.processGroupingRequest(requestDetails.uri, requestDetails.httpMethod, requestDetails.queryParameters, "")
new ResponseEntity[Object](response, HttpStatus.OK)
}

indexAnalyzer not found in spring boot elasticsearch

In the Field Annotation the indexAnalyzer not found, Is this any version problem.
Error:- The attribute indexAnalyzer is undefined for the annotation type Field
My Gradle:-
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile group: 'commons-validator', name: 'commons-validator', version: '1.6'
//compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-elasticsearch', version: '1.2.5.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-elasticsearch', version: '1.5.6.RELEASE'
compile('org.springframework.boot:spring-boot-starter-data-elasticsearch:1.3.2.RELEASE')
compile group: 'net.java.dev.jna', name: 'platform', version: '3.5.0'
testCompile('org.springframework.boot:spring-boot-starter-test')
}

Gradle dependencies for Magnolia not found

I'm trying to create a new project with Magnolia and the Gradle dependencies are not found.
Tried this
https://mvnrepository.com/artifact/info.magnolia.blossom/magnolia-module-blossom
Gradle build returns
Could not find info.magnolia.blossom:magnolia-module-blossom:3.1.3.
The gradle file content:
buildscript {
ext {
springBootVersion = '1.3.5.RELEASE'
}
repositories {
mavenCentral()
maven {
url "http://mvnrepository.com/artifact/org.hibernate/hibernate-search-orm"
url "https://mvnrepository.com/artifact/info.magnolia.blossom/magnolia-module-blossom/3.1.3"
url "https://repo.spring.io/libs-milestone"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
apply plugin: 'war'
war {
baseName = 'test.app'
version = '1.0.0'
}
springBoot {
mainClass = 'com.test.app.Application'
executable = true
}
bootRun {
addResources = true
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-configuration-processor')
compile('org.springframework.boot:spring-boot-actuator-docs')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-redis')
compile('org.springframework.boot:spring-boot-starter-jersey')
compile('org.springframework.boot:spring-boot-starter-mail')
compile('org.springframework.boot:spring-boot-starter-remote-shell')
compile('org.springframework.boot:spring-boot-starter-security')
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-websocket')
compile('org.springframework.session:spring-session:1.2.2.RELEASE')
compile group: 'org.hibernate', name: 'hibernate-search-orm', version: '5.1.0.Final'
compile group: 'com.ryantenney.metrics', name: 'metrics-spring', version: '3.1.3'
compile group: 'io.dropwizard.metrics', name: 'metrics-annotation', version: '3.1.2'
compile group: 'io.dropwizard.metrics', name: 'metrics-graphite', version: '3.1.2'
compile group: 'io.dropwizard.metrics', name: 'metrics-core', version: '3.1.2'
compile group: 'io.dropwizard.metrics', name: 'metrics-jvm', version: '3.1.2'
compile group: 'commons-fileupload', name: 'commons-fileupload', version: '1.3.1'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
compile group: 'commons-validator', name: 'commons-validator', version: '1.5.1'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.2'
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1'
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-jasper', version: '8.5.0'
compile group: 'org.springframework.security', name: 'spring-security-taglibs', version: '4.1.3.RELEASE'
//https://mvnrepository.com/artifact/org.springframework.security/spring-security-messaging
compile group: 'org.springframework.security', name: 'spring-security-messaging', version: '4.1.3.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version: '1.3.6.RELEASE'
// Magnolia
compile group: 'info.magnolia', name: 'magnolia-core', version: '5.5'
compile group: 'info.magnolia.blossom', name: 'magnolia-module-blossom', version: '3.1.3'
compile group: 'jstl', name: 'jstl', version: '1.2'
compile('org.ocpsoft.prettytime:prettytime:4.0.1.Final')
runtime('mysql:mysql-connector-java')
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
testCompile('org.springframework.boot:spring-boot-starter-test')
}
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'
}
}
Are there other repositories I can use?
Best Regards,
Razvan
I see two issues you might have
First you added the additional repositories to the repositories block inside the buildscript block. Those are only used for the dependencies of the build script itself like the spring plugin.
What you want is to add at least the blossom repository to the second repositories block where you define the repositories for the dependencies of your application.
The other issue I see is the referenced repositories might be wrong. First only use one url per maven block and the URL might not point to correct maven repositories. Try something like the following:
buildscript {...}
repositories {
mavenCentral()
maven {
url "https://nexus.magnolia-cms.com/content/groups/public/"
}
maven {
url "https://repo.spring.io/libs-milestone"
}
}
Hope that helps.

Gradle replace transitive dependency log4j with logback

is it possible to replace log4j from a transitive dependency with logback?
Here are my gradle dependencies (https://github.com/geoHeil/lab04/blob/master/build.gradle):
dependencies {
compile group: 'org.apache.hadoop', name: 'hadoop-common', version: '2.7.1'
compile group: 'org.apache.hadoop', name: 'hadoop-client', version: '2.7.1'
compile group: 'org.apache.hadoop', name: 'hadoop-mapreduce-client-core', version: '2.7.1'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.13'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.3'
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.name == 'log4j') {
//prefer 'log4j-over-slf4j' over 'log4j', with fixed version:
details.useTarget "ch.qos.logback:logback-classic:1.1.3"
}
}
My case:
I am new to Gradle
Working on a Hadoop project
Want to use a current logger e.g. logback
For now it does not seem to work even though log4j should have been replaced. And the warning persists:
log4j:WARN No appenders could be found for logger
(org.apache.hadoop.util.Shell).
log4j:WARN Please initialize the log4j system properly.
I am not sure if this is the best or "correct" answer. But at least the WARN messages have disappeared:
dependencies {
compile group: 'org.apache.hadoop', name: 'hadoop-common', version: '2.7.1'
compile group: 'org.apache.hadoop', name: 'hadoop-client', version: '2.7.1'
compile group: 'org.apache.hadoop', name: 'hadoop-mapreduce-client-core', version: '2.7.1'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.13'
compile group: 'org.slf4j', name: 'log4j-over-slf4j', version: '1.7.13'
compile group: 'commons-io', name: 'commons-io', version: '2.4'
compile 'ch.qos.logback:logback-classic:1.1.3'
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.name == 'slf4j-log4j12') {
//prefer 'log4j-over-slf4j' over 'log4j', with fixed version:
details.useTarget "ch.qos.logback:logback-classic:1.1.3"
}
}
}

Resources