I'm using Gradle to compile project, when I run it with bootRun it output the following error:
can't find symbol isEmpty, that's a lot of them, I knew that's something with the java version, but I don't know how to correct them, it's a shame they don't allow short version post.
Here is my gradle config:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id 'org.springframework.boot' version '2.2.0.M5'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
id 'net.ltgt.apt' version '0.20'
}
apply plugin: 'net.ltgt.apt-idea'
apply plugin: 'kotlin'
apply plugin: 'net.ltgt.apt-eclipse'
group = 'com.fanjiu'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
mapstruct
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
}
ext {
set('springCloudVersion', "Hoxton.M2")
generatedMapperSourcesDir = "${buildDir}/generated-src/mapstruct/main"
}
sourceSets.main {
ext.originalJavaSrcDirs = java.srcDirs
java.srcDir "${generatedMapperSourcesDir}"
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-batch'
implementation 'org.springframework.boot:spring-boot-starter-cloud-connectors'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation('com.github.binarywang:wx-java-miniapp-spring-boot-starter:3.5.0')
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-security")
compile('org.modelmapper:modelmapper:2.3.5')
implementation 'org.springframework.cloud:spring-cloud-starter'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'mysql:mysql-connector-java'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
implementation "org.mapstruct:mapstruct"
annotationProcessor "org.mapstruct:mapstruct-processor"
compileOnly 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
compile 'org.mapstruct:mapstruct:1.3.0.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.3.0.Final'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile 'com.qiniu:qiniu-java-sdk:7.2.+'
compile 'com.alibaba:fastjson:1.2.61'
compile group: 'org.ocpsoft.prettytime', name: 'prettytime', version: '4.0.2.Final'
compile group: 'org.ocpsoft.prettytime', name: 'prettytime-nlp', version: '4.0.2.Final'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
test {
useJUnitPlatform()
}
task generateMainMapperClasses(type: JavaCompile) {
ext.aptDumpDir = file( "${buildDir}/tmp/apt/mapstruct" )
destinationDir = ext.aptDumpDir
classpath = compileJava.classpath + configurations.mapstruct
source = sourceSets.main.originalJavaSrcDirs
ext.sourceDestDir = file ( "$generatedMapperSourcesDir" )
options.define(
compilerArgs: [
"-nowarn",
"-proc:only",
"-encoding", "UTF-8",
"-processor", "org.mapstruct.ap.MappingProcessor",
"-s", ext.sourceDestDir.absolutePath,
"-source", rootProject.sourceCompatibility,
"-target", rootProject.sourceCompatibility,
]
);
inputs.dir source
outputs.dir generatedMapperSourcesDir;
doFirst {
ext.sourceDestDir.mkdirs()
}
doLast {
ext.aptDumpDir.delete()
}
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
//compileJava.dependsOn generateMainMapperClasses
Yes. JDK version, upgrade JDK version solve the problem. And update the file with sourceCompatibility = '13'
Related
when I start app in idea it works well but when i try to start this app from cmd like java -jar build/libs/dev-0.0.1-SNAPSHOT.jar
i get this error
21:02:06.634 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
this is my build.gradle
/*
* This file was generated by the Gradle 'init' task.
*/
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.6.7"
}
}
plugins {
id 'java'
id 'groovy'
id 'maven-publish'
}
repositories {
mavenLocal()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-security:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-validation:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-web:2.6.7'
implementation 'org.springframework.boot:spring-boot-configuration-processor:2.6.7'
implementation 'org.springframework:spring-aop:5.3.19'
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
testCompileOnly 'org.projectlombok:lombok:1.18.24'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
implementation 'org.mapstruct:mapstruct:1.4.2.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'com.vladmihalcea:hibernate-types-52:2.16.2'
implementation 'org.flywaydb:flyway-core:8.5.10'
runtimeOnly 'org.postgresql:postgresql:42.3.4'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.6.7'
testImplementation 'org.springframework.security:spring-security-test:5.6.3'
testImplementation 'org.codehaus.groovy:groovy-all:3.0.10'
testImplementation 'org.spockframework:spock-core:2.1-groovy-3.0'
testImplementation 'org.spockframework:spock-spring:2.1-groovy-3.0'
testImplementation 'org.testcontainers:spock:1.17.1'
testImplementation "org.testcontainers:postgresql:1.17.1"
}
group = 'com.dev'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
targetCompatibility = '17'
java.sourceCompatibility = JavaVersion.VERSION_17
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
compileJava {
options.compilerArgs += "-Amapstruct.defaultComponentModel=spring"
options.compilerArgs += "-Amapstruct.unmappedTargetPolicy=WARN"
}
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes(
'Main-Class': 'com.dev.DevApplication',
'Class-Path': configurations.runtimeClasspath.files.collect { "lib/$it.name" }.join(' ')
)
}
from{
configurations.runtimeClasspath.collect{ it.isDirectory() ? it : zipTree(it)}
}
}
So i edited build.gradle like this and it is working now
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
id 'java'
id 'groovy'
id 'maven-publish'
id 'org.springframework.boot' version '2.6.7'
}
repositories {
mavenLocal()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-security:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-validation:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-web:2.6.7'
implementation 'org.springframework.boot:spring-boot-configuration-processor:2.6.7'
implementation 'org.springframework:spring-aop:5.3.19'
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
testCompileOnly 'org.projectlombok:lombok:1.18.24'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
implementation 'org.mapstruct:mapstruct:1.4.2.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'com.vladmihalcea:hibernate-types-52:2.16.2'
implementation 'org.flywaydb:flyway-core:8.5.10'
runtimeOnly 'org.postgresql:postgresql:42.3.4'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.6.7'
testImplementation 'org.springframework.security:spring-security-test:5.6.3'
testImplementation 'org.codehaus.groovy:groovy-all:3.0.10'
testImplementation 'org.spockframework:spock-core:2.1-groovy-3.0'
testImplementation 'org.spockframework:spock-spring:2.1-groovy-3.0'
testImplementation 'org.testcontainers:spock:1.17.1'
testImplementation "org.testcontainers:postgresql:1.17.1"
}
group = 'com.dev'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
targetCompatibility = '17'
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
compileJava {
options.compilerArgs += "-Amapstruct.defaultComponentModel=spring"
options.compilerArgs += "-Amapstruct.unmappedTargetPolicy=WARN"
}
jar {
enabled = false
}
springBoot {
mainClass = 'com.dev.DevApplication'
}
guys.
I'm building a spring boot service. Right now I'm setting it up to query a local MySQL instance with jooq.
However, ./gradlew build gives error Unable to load class 'com.mysql.jdbc.Driver'.
Am I missing anything?
More Info
I'm able to see the com.mysql.jdbc.Driver class in Intellij.
Here is my gradle script.
import nu.studer.gradle.jooq.JooqEdition
plugins {
id 'org.springframework.boot' version '2.6.2'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'nu.studer.jooq' version '3.0.2'
id 'java'
}
if(JavaVersion.current() != JavaVersion.VERSION_11){
throw new GradleException("This build must be run with java 11")
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
repositories {
mavenCentral()
}
group = 'snorlax'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
//create a fat Jar with all dependencies
jar {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
from {
configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
manifest {
attributes "Main-Class": "com.snorlax.userservice.MainApplication"
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
dependencies {
// Spring boot
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// Swagger
implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
// Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// RDS Connection
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'mysql:mysql-connector-java:8.0.27'
implementation 'com.amazonaws.secretsmanager:aws-secretsmanager-jdbc:1.0.6'
// JOOQ
implementation 'org.springframework.boot:spring-boot-starter-jooq:2.6.2'
implementation 'org.jooq:jooq-meta:3.15.5'
implementation 'org.jooq:jooq-codegen:3.15.5'
}
test {
useJUnitPlatform()
}
/************************
jooq code generation
*************************/
import org.jooq.codegen.GenerationTool
import org.jooq.meta.jaxb.*
GenerationTool.generate(new Configuration()
.withJdbc(new Jdbc()
.withDriver('com.mysql.jdbc.Driver')
.withUrl('jdbc:mysql://127.0.0.1:3306/SnorlaxRds')
.withUser('root')
.withPassword('123456'))
.withGenerator(new Generator()
.withDatabase(new Database())
.withGenerate(new Generate()
.withPojos(true)
.withDaos(true))
.withTarget(new Target()
.withPackageName('com.snorlax.userservice')
.withDirectory('src/main/java/jooq'))))
My bad.
I missed the buildscript { } block mentioned here: https://www.jooq.org/doc/latest/manual/code-generation/codegen-gradle.
After adding below section, now my gradle build works.
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'org.jooq:jooq-codegen:3.16.2'
classpath 'mysql:mysql-connector-java:8.0.27'
}
}
Full version
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'org.jooq:jooq-codegen:3.16.2'
classpath 'mysql:mysql-connector-java:8.0.27'
}
}
plugins {
id 'org.springframework.boot' version '2.6.2'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
if(JavaVersion.current() != JavaVersion.VERSION_11){
throw new GradleException("This build must be run with java 11")
}
repositories {
mavenCentral()
}
group = 'snorlax'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
//create a fat Jar with all dependencies
jar {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
from {
configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
manifest {
attributes "Main-Class": "com.snorlax.userservice.MainApplication"
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
dependencies {
// Spring boot
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// Swagger
implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
// Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// RDS Connection
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'mysql:mysql-connector-java:8.0.27'
// AWS secretes manager
implementation 'com.amazonaws.secretsmanager:aws-secretsmanager-jdbc:1.0.6'
// JOOQ
implementation 'org.springframework.boot:spring-boot-starter-jooq'
implementation 'org.jooq:jooq-meta:3.16.2'
compileOnly 'org.jooq:jooq-codegen:3.16.2'
}
test {
useJUnitPlatform()
}
/************************
jooq code generation
*************************/
import org.jooq.codegen.GenerationTool;
import org.jooq.meta.jaxb.*;
task generate {
def outputDirectory = projectDir.toString() + '/src/main/java'
println outputDirectory
def configuration = new Configuration()
.withJdbc(new Jdbc()
.withDriver('com.mysql.cj.jdbc.Driver')
.withUrl('jdbc:mysql://127.0.0.1:3306/snorlaxRds')
.withUser('root')
.withPassword('123456'))
.withGenerator(new Generator()
.withDatabase(new Database().withInputSchema("snorlaxRds"))
.withGenerate(new Generate()
.withPojos(true)
.withDaos(true))
.withTarget(new Target()
.withPackageName('snorlax.userservice.database')
.withDirectory(outputDirectory)));
doLast {
GenerationTool.generate(configuration)
}
}
I am studying spring webflux, but the generated folder is created when the server starts. Do you know why?
If you restart the server after deleting the generated folder, it will be created again.
The build.gradle file was configured as follows.
spring boot 2.2.7.RELEASE version and using jdk 8.
build.gradle
buildscript {
ext {
restDocsVersion = "2.0.2.RELEASE"
}
dependencies {
classpath "org.asciidoctor:asciidoctor-gradle-plugin:1.5.3"
}
}
plugins {
id "org.springframework.boot" version "2.2.7.RELEASE"
id "io.spring.dependency-management" version "1.0.9.RELEASE"
id "java"
id "groovy"
id "org.asciidoctor.convert" version "2.4.0"
}
ext {
snippetsDir = file("build/generated-snippets")
}
test {
useJUnitPlatform()
}
asciidoctor {
inputs.dir snippetsDir
dependsOn test
}
bootJar {
dependsOn asciidoctor
from("${asciidoctor.outputDir}/html5") {
into "static/docs"
}
dependsOn "copyDocs"
}
task copyDocs(type: Copy) {
from "${asciidoctor.outputDir}/html5"
into "src/main/resources/static/docs"
}
group = "com.example"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
build {
dependsOn clean
}
repositories {
mavenCentral()
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-aop"
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-webflux"
compile "org.springframework.boot:spring-boot-starter-data-redis-reactive"
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"
}
testImplementation "io.projectreactor:reactor-test"
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
compile group: "com.fasterxml.jackson.core", name: "jackson-core", version: "2.9.8"
compile group: "com.fasterxml.jackson.core", name: "jackson-annotations", version: "2.9.8"
compile group: "com.fasterxml.jackson.core", name: "jackson-databind", version: "2.9.8"
compile group: "com.googlecode.json-simple", name: "json-simple", version: "1.1.1"
asciidoctor "org.springframework.restdocs:spring-restdocs-asciidoctor:${restDocsVersion}"
testCompile "org.springframework.restdocs:spring-restdocs-webtestclient:${restDocsVersion}"
compile group: "org.codehaus.groovy", name: "groovy-all", version: "2.5.8"
}
I am trying to integrate Open Clover into my Gradle build process and was following the following guide:
When I added it to my build.gradle - I got the following error:
* * What went wrong:
A problem occurred evaluating root project 'Enjin-Coin-Java-SDK'.
> Could not find method cloverCompile() for arguments [org.openclover:clover:4.2.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler..
My build.gradle file is as follows:
buildscript {
repositories {
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'org.openclover:clover:4.2.0'
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '1.2.4'
id 'java'
}
sourceSets {
clover {
java {
srcDir "$buildDir/sources-instr"
}
}
}
apply from: 'gradle/util.gradle'
subprojects {
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
group = 'com.myproject'
version = '0.0.1-SNAPSHOT'
idea {
module {
scopes.PROVIDED.plus += [configurations.shadow]
}
}
tasks.build.dependsOn(shadowJar)
artifacts.archives shadowJar
tasks.withType(AbstractCompile) {
classpath += configurations.shadow
}
ext {
mockito = '2.9.0'
junit = '4.12'
powermock = '1.7.3'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
// testCompile dependencies
testCompile group: 'org.mockito', name: 'mockito-core', version: mockito
testCompile group: 'junit', name: 'junit', version: junit
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: powermock
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: powermock
cloverCompile 'org.openclover:clover:4.2.0'
}
jar {
archiveName = "${project.name}-slim.jar"
}
shadowJar {
archiveName = "${project.name}.jar"
}
install {
repositories.mavenInstaller {
pom.artifactId = "sdk-${project.name}"
}
}
}
configurations {
cloverRuntime
cloverRuntime.extendsFrom cloverCompile
}
task cloverInstr() {
inputs.files sourceSets.main.allJava
outputs.dir "$buildDir/sources-instr"
doFirst {
def argsList = ["--initstring", "${buildDir}/clover/clover.db", "-d", "${buildDir}/sources-instr"]
argsList.addAll(inputs.files.files.collect({ file ->
file.absolutePath
}))
String[] args = argsList.toArray()
com.atlassian.clover.CloverInstr.mainImpl(args)
}
}
cloverClasses.dependsOn cloverInstr
test {
def cloverClasspath = configurations.testRuntime + configurations.cloverRuntime + sourceSets.test.output + sourceSets.clover.output
classpath = cloverClasspath
}
task cloverReport {
inputs.dir "${buildDir}/clover"
outputs.dir "${reportsDir}/clover"
onlyIf {
file("${buildDir}/clover/clover.db").exists()
}
doFirst {
def argsList = ["--initstring", "${buildDir}/clover/clover.db",
"-o", "${reportsDir}/clover"]
String[] args = argsList.toArray()
com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
}
}
The contents of util.gradle are as follows
ext.scriptFile = {
String fileName ->
return new File(new File(rootDir, 'gradle'), fileName)
}
Can anyone offer any assistance in how to resolve this?
Use the following script to integrate clover into your project:
buildscript {
repositories {
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
jcenter()
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '1.2.4'
id "com.bmuschko.clover" version "2.1.3"
}
apply from: 'gradle/util.gradle'
subprojects {
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'com.bmuschko.clover'
group = 'com.myproject'
version = '0.0.1-SNAPSHOT'
idea {
module {
scopes.PROVIDED.plus += [configurations.shadow]
}
}
tasks.build.dependsOn(shadowJar)
artifacts.archives shadowJar
tasks.withType(AbstractCompile) {
classpath += configurations.shadow
}
ext {
mockito = '2.9.0'
junit = '4.12'
powermock = '1.7.3'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
// testCompile dependencies
testCompile group: 'org.mockito', name: 'mockito-core', version: mockito
testCompile group: 'junit', name: 'junit', version: junit
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: powermock
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: powermock
clover 'org.openclover:clover:4.2.0'
}
jar {
archiveName = "${project.name}-slim.jar"
}
shadowJar {
archiveName = "${project.name}.jar"
}
install {
repositories.mavenInstaller {
pom.artifactId = "sdk-${project.name}"
}
}
}
There's no need for manual integration if ready-to-use plugin is available.
I've a Spring Boot Application with main class:
#SpringBootApplication
public class MyApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(MyApplication .class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application){
return application.sources(applicationClass);
}
private static Class<MyApplication > applicationClass = MyApplication .class;
}
With gradle.build:
version '1.0'
// dependencies for command line
buildscript {
ext {
springBootVersion = '1.4.3.RELEASE'
dependencyManagementVersion = '0.6.0.RELEASE'
}
repositories {
jcenter()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
classpath "io.spring.gradle:dependency-management-plugin:${dependencyManagementVersion}"
}
}
apply plugin: "io.spring.dependency-management"
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
apply plugin: 'eclipse'
apply plugin: 'idea'
// JDK 8
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
repositories {
jcenter()
}
ext {
springCloudVersion = 'Brixton.SR4'
springBootVersion = '1.4.3.RELEASE'
swaggerVersion = '2.4.0'
jodaTimeVersion = '2.9.4'
jacksonJodaVersion = '2.5.1'
junitVersion = '4.12'
springWsTestVersion = '2.2.3.RELEASE'
lombokVersion = '1.16.10'
jsonPathVersion = '2.2.0'
ehcacheVersion = '3.2.0'
javaxCacheVersion = '1.0.0'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
mavenBom "org.springframework.boot:spring-boot-starter-parent:${springBootVersion}"
}
}
sourceSets {
test {
java {
srcDir 'src/test/unit/java'
}
resources {
srcDir 'src/test/unit/resources'
}
}
}
tasks.withType(JavaExec) {
if (System.getProperty("DEBUG", 'false') == 'true') {
jvmArgs '-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006'
}
}
dependencies {
// https://mvnrepository.com/artifact/javax/javaee-api
compile group: 'javax', name: 'javaee-api', version: '7.0'
/* core libraries */
compile('org.springframework.cloud:spring-cloud-starter-config') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
compile('org.springframework.boot:spring-boot-starter-web') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
compile("org.springframework.boot:spring-boot-starter-hateoas"){
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
compile 'org.springframework.ws:spring-ws-core'
// tag::actuator[]; for #RefreshScope
compile("org.springframework.boot:spring-boot-starter-actuator"){
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
// end::actuator[]
// logging
compile('org.springframework.boot:spring-boot-starter-log4j2')
compile('com.fasterxml.jackson.dataformat:jackson-dataformat-yaml')
compile('com.fasterxml.jackson.core:jackson-databind')
// embedded server
providedRuntime ('org.springframework.boot:spring-boot-starter-tomcat')
// https://mvnrepository.com/artifact/org.projectlombok/lombok-maven
compile "org.projectlombok:lombok:${lombokVersion}"
// https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path
// A Java DSL for reading JSON documents
compile "com.jayway.jsonpath:json-path:${jsonPathVersion}"
//for EhCache
// https://mvnrepository.com/artifact/org.ehcache/ehcache
compile "org.ehcache:ehcache:${ehcacheVersion}"
// https://mvnrepository.com/artifact/javax.cache/cache-api
compile "javax.cache:cache-api:${javaxCacheVersion}"
// utilities
compile "io.springfox:springfox-swagger2:${swaggerVersion}"
compile "io.springfox:springfox-swagger-ui:${swaggerVersion}"
compile "joda-time:joda-time:${jodaTimeVersion}"
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:${jacksonJodaVersion}"
compile ("org.springframework.boot:spring-boot-starter-aop") {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
compile "org.aspectj:aspectjweaver:1.8.8"
/* plugins */
/* test libraries */
// unit
testCompile "junit:junit:${junitVersion}"
testCompile "org.springframework.boot:spring-boot-starter-test"
testCompile "org.springframework.ws:spring-ws-test:${springWsTestVersion}"
}
war {
archiveName = "${project.name}.war"
manifest {
attributes 'Main-Class': 'com..content.MyApplication'
}
}
When I try to deploy the war file on WebSphere Application Server 9.0 Traditional, it starts but takes very long time. Without war file, server starts and stops very normally, but with application, server hangs.
Am I missing something?
Thank you for help!!
The startup delay is probably caused by CDI's implicit bean archive scanning. If you are not using CDI, you can disable implicit bean archives with com.ibm.ws.cdi.enableImplicitBeanArchives=false.
You can find a much more detailed explanation in this tech note:
Custom Properties for improving application startup in WebSphere Application Server