Unable to run gradle program in command line - spring-boot

gradle test
Task :compileJava FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':compileJava'.
Could not resolve all dependencies for configuration ':detachedConfiguration1'.
Could not resolve org.springframework.boot:spring-boot-dependencies:2.2.7.RELEASE.
Required by:
project :
> Could not resolve org.springframework.boot:spring-boot-dependencies:2.2.7.RELEASE.
> Could not get resource 'https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-dependencies/2.2.7.RELEASE/spring-boot-dependencies-2.2.7.
RELEASE.pom'.
> Could not HEAD 'https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-dependencies/2.2.7.RELEASE/spring-boot-dependencies-2.2.7.RELEA
SE.pom'.
> repo.maven.apache.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

buildscript {
repositories {
maven {
url "https://rb-artifactory.bosch.com/artifactory/gradle-plugins-remote/"
credentials {
username "***"
password "***"
}
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.2.7.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "io.spring.dependency-management"
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
apply plugin: 'jacoco'
apply plugin: 'application'
jacocoTestReport{
reports{
xml.enabled true
csv.enabled true
html.enabled true
}
}
// This comes out to package + '.' + mainClassName
mainClassName = 'com.bosch.shop.ShopAuthentication'
repositories {
mavenCentral()
/* maven {
credentials {
username "EED1COB"
password "AP28P2xA2dB6pCNDcbrxx7uVuNo"
}
url "https://rb-artifactory.bosch.com/artifactory/gradle-mvn-remote/"
}*/
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
configurations {
providedRuntime
}
bootRun {
// allows ./gradlew bootRun -Dspring.profiles.active=dev
systemProperties System.properties
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web"){
exclude group: 'org.apache.tomcat'
}
implementation( "mysql:mysql-connector-java:5.1.28" )
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation('org.springframework.boot:spring-boot-starter-data-mongodb')
implementation("io.springfox:springfox-swagger2:2.6.1")
//implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
implementation("io.springfox:springfox-swagger-ui:2.6.1")
//implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
implementation("com.google.code.gson:gson:2.8.2")
implementation("com.ocpsoft:ocpsoft-pretty-time:1.0.7")
implementation('org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2')
implementation ('org.json:json:20180130')
implementation("com.jayway.jsonpath:json-path:2.0.0")
implementation("com.mashape.unirest:unirest-java:1.4.9")
implementation("io.jsonwebtoken:jjwt:0.5.1")
implementation platform('org.springframework.boot:spring-boot-dependencies:2.0.5.RELEASE')
implementation 'org.springframework.boot:spring-boot-starter-web'
//implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.10.2'
//overridden-
//implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.8.0-beta2'
implementation group: 'com.google.guava', name: 'guava', version: '27.1-jre'
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '9.0.37'
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-websocket', version: '9.0.37'
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-el', version: '9.0.37'
implementation("com.sun.jersey:jersey-client:1.9.1")
implementation group: 'com.zaxxer', name: 'HikariCP', version: '3.2.0'
implementation group: 'org.locationtech.spatial4j', name: 'spatial4j', version: '0.7'
testImplementation('org.springframework.boot:spring-boot-starter-test')
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
testImplementation("junit:junit:4.12")
testImplementation group: 'org.mockito', name: 'mockito-core', version: '2.23.0'
implementation group: 'net.bytebuddy', name: 'byte-buddy', version: '1.9.7'
implementation group: 'net.bytebuddy', name: 'byte-buddy-agent', version: '1.9.7'
// https://mvnrepository.com/artifact/com.azure/azure-core
implementation group: 'com.azure', name: 'azure-core', version: '1.22.0'
// https://mvnrepository.com/artifact/com.azure/azure-messaging-servicebus
implementation group: 'com.azure', name: 'azure-messaging-servicebus', version: '7.4.2'
implementation group: 'io.projectreactor', name: 'reactor-core', version: '3.4.12'
implementation group: 'com.azure', name: 'azure-core-amqp', version: '2.3.4'
implementation group: 'org.mongodb', name: 'mongo-java-driver', version: '3.12.10'
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.apache.logging.log4j') {
details.useVersion '2.15.0'
}
}
}

Related

SpringBoot FlywayCallback not present

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 ?

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"))
}
}
}

Liquibase changelog not running in spring boot

I´m trying to run a springboot api and configure the database using liquibase.
The problem here is I followed all steps described in several tutorial but the changelog is never executed.
The code:
Gradle config:
group = 'com.strixtools'
version = '0.0.1-SNAPSHOT'
description = """Strix Tools"""
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.1.RELEASE"
classpath "gradle.plugin.com.palantir.gradle.docker:gradle-docker:0.20.1"
}
}
group = 'strixtools'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'com.palantir.docker'
bootJar {
baseName = 'gs-spring-boot-docker'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
configurations.all {
exclude module: "spring-boot-starter-logging"
exclude module: "logback-classic"
}
compile ('org.springframework.boot:spring-boot-starter:2.1.1.RELEASE')
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version:'2.1.1.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version:'2.1.1.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-devtools', version:'2.1.1.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version:'2.1.1.RELEASE'
compile group: 'org.springframework.security.oauth.boot', name: 'spring-security-oauth2-autoconfigure', version: '2.1.1.RELEASE'
compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.4'
compile group: 'io.jsonwebtoken', name: 'jjwt', version:'0.9.0'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version:'2.6.5'
compile group: 'org.liquibase', name: 'liquibase-core'
compile group: 'com.h2database', name: 'h2', version:'1.4.196'
runtime group: 'org.postgresql', name: 'postgresql'
testCompile(group: 'org.springframework.boot', name: 'spring-boot-starter-test', version:'2.1.1.RELEASE')
compile group: 'org.springframework.boot', name: 'spring-boot-starter-log4j2', version:'2.1.1.RELEASE'
}
task stage {
dependsOn build
}
task unpack(type: Copy) {
dependsOn bootJar
from(zipTree(tasks.bootJar.outputs.files.singleFile))
into("build/dependency")
}
docker {
name "${project.group}/${bootJar.baseName}"
copySpec.from(tasks.unpack.outputs).into("dependency")
buildArgs(['DEPENDENCY': "dependency"])
}
aplication.yml
strix-api:
host: https://aaa.com
client: asdasdasfasdf
secret: afadsfsdaf
user: afdadsfsadf
pass: afadsfsdafsdaf
---
spring:
profiles: local
datasource:
url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
username: sa
password:
liquibase:
change-log: classpath:db/changelog-master.xml
enabled: true
drop-first: true
jpa:
hibernate:
ddl-auto: none
show-sql: true
h2:
console:
enabled: true
and my SpringAplication class
#SpringBootApplication
public class StrixToolsApplication {
public static void main(String[] args) {
SpringApplication.run(StrixToolsApplication.class, args);
}
//TODO: we should move this to another side
#Bean(name = "messageSource")
public ReloadableResourceBundleMessageSource messageSource() {
ReloadableResourceBundleMessageSource messageBundle = new ReloadableResourceBundleMessageSource();
messageBundle.setBasename("classpath:messages/messages");
messageBundle.setDefaultEncoding("UTF-8");
return messageBundle;
}
#Bean
public BCryptPasswordEncoder bCryptPasswordEncoder() {
return new BCryptPasswordEncoder();
}
}
The problem is liquibase is never executing. If I change the changelog name to anthing else it doesn't even throws an error.
Thanks for your help
Regards
In my case the problem was that I had a dependency declared for the gradle plugin, like so
liquibaseRuntime("org.liquibase:liquibase-core:3.8.1")
but not for liquibase at runtime, like so
runtimeOnly("org.liquibase:liquibase-core:3.8.1")
Maybe you are missing the right version of liquibase. Try with 2.0.1.
Here you have a small sample: (you can refactor the notation that you are using for versions and groups).
apply plugin: 'liquibase'
plugins {
id 'io.spring.dependency-management' version '1.0.5.RELEASE'
id 'org.liquibase.gradle' version '2.0.1'
}
ependencies {
implementation('org.springframework.boot:spring-boot-starter-actuator')
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('org.springframework.boot:spring-boot-starter-security')
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
implementation('org.springframework.boot:spring-boot-starter-validation')
implementation('org.liquibase:liquibase-core')
runtime 'mysql:mysql-connector-java'
liquibaseRuntime group: 'org.liquibase', name: 'liquibase-core', version: liquibaseCoreVersion
liquibaseRuntime group: 'org.liquibase', name: 'liquibase-groovy-dsl', version: liquibaseGroovyDslVersion
liquibaseRuntime 'mysql:mysql-connector-java'
}
liquibase {
activities {
main {
changeLogFile 'src/main/resources/db/liquibase-changelog.xml'
url 'jdbc:mysql://' + System.env.DATABASE_HOST + ':' + System.env.DATABASE_PORT + '/' + System.env.DATABASE_NAME + '?useSSL=false'
username System.env.DATABASE_USER
password System.env.DATABASE_PASSWORD
driver 'com.mysql.jdbc.Driver'
}
}
}

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.

ClassCastException with Spring-Websocket because of Tomcat ServerContainer

While trying to connect to Spring Websocket with SockJS, I am getting an error
org.springframework.web.util.NestedServletException: Request processing failed;
nested exception is org.springframework.web.socket.sockjs.SockJsException:
Uncaught failure in SockJS request, uri=http://localhost:8083//subscribe/info/771/nay07fet/websocket;
nested exception is org.springframework.web.socket.sockjs.SockJsTransportFailureException:
WebSocket handshake failure; nested exception is java.lang.ClassCastException:
org.eclipse.jetty.websocket.jsr356.server.ServerContainer cannot be cast
to org.apache.tomcat.websocket.server.WsServerContainer
From online I figured out that I shall disable Tomcat in Classpath to overcome it, but no matter how I try, I can not get rid of Tomcat.
How I can reliably exclude tomcat from any project? Note that I found it in several places.
My current Dependency tree is here: http://pastebin.com/pH1iQejd
and it contains some tomcat. I need to get rid of everything that might cause that type confusion.
Here's my gradle.build (I tried some exlcudes but without success):
group 'com.company'
if (!hasProperty("buildNumber")) {
version "1.0.0-SNAPSHOT"
} else {
version "1.0.${buildNumber}-SNAPSHOT"
}
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE")
classpath("gradle.plugin.com.boxfuse.client:flyway-release:4.0.1")
classpath fileTree(dir: 'libs', include: '*.jar')
classpath fileTree(dir: 'src/main/resources/db/migration', include: '*.sql')
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2"
}
}
dependencies {
// tag::jetty[]
compile("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-tomcat"
exclude module: 'spring-boot-starter-logging'
}
compile("org.springframework.boot:spring-boot-starter-jetty") {
exclude module: "spring-boot-starter-tomcat"
exclude module: 'spring-boot-starter-logging'
}
// end::jetty[]
// tag::actuator[]
compile("org.springframework.boot:spring-boot-starter-actuator")
compile("org.springframework.boot:spring-boot-starter-data-jpa"){
exclude module: "spring-boot-starter-tomcat"
exclude module: 'spring-boot-starter-logging'
}
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile("org.springframework.boot:spring-boot-starter-websocket")
// http://mvnrepository.com/artifact/org.springframework.security/spring-security-core
compile group: 'org.springframework.security', name: 'spring-security-core', version: '4.1.0.RELEASE'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.+'
compile group: 'com.google.code.gson', name: 'gson', version: '2.5'
compile group: 'com.rabbitmq', name: 'amqp-client', version: '3.5.6'
compile group: 'commons-configuration', name: 'commons-configuration', version: '1.9'
compile group: 'com.google.guava', name: 'guava', version: '18.0'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.5'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.5'
compile("org.springframework:spring-messaging")
compile 'org.springframework.amqp:spring-rabbit:1.5.5.RELEASE'
compile("com.h2database:h2")
compile 'org.quartz-scheduler:quartz:2.2.1'
compile group: 'joda-time', name: 'joda-time', version: '2.3'
//compile("com.npspot:jtransit-light:1.0.6")
compile("io.fastjson:boon:0.33")
compile fileTree(dir: 'libs', include: '*.jar')
// end::actuator[]
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile("org.springframework.boot:spring-boot-starter-test")
}
configurations {
compile.exclude module: "spring-boot-starter-tomcat"
compile.exclude module: 'spring-boot-starter-logging'
runtime.exclude module: "spring-boot-starter-tomcat"
runtime.exclude module: 'spring-boot-starter-logging'
}
test {
reports {
junitXml.enabled = true
html.enabled = false
}
}
springBoot {
executable = true
}
I was facing this problem as well. I solved it by adding the exclude clause to the websocket dependency, i.e.:
compile("org.springframework.boot:spring-boot-starter-websocket") {
exclude module: "spring-boot-starter-tomcat"
}
After this, I realized it wasn't necessary to have the exclusion on all the other ones; it's only necessary on starter-web and starter-websocket.

Resources