Slf4j with log4j2 not working Spring boot 1.4.3.RELEASE - spring

I was using Spring boot 1.3.6.RELEASE and log4j2.yml as below:
Configuration:
status: info
Properties:
Property:
name: log-path
value: "/dvl-log/pol/apps/logs/api"
Appenders:
Console:
- name: Console
target: SYSTEM_OUT
PatternLayout:
Pattern: "%d{HH:mm:ss.SSS} %-5level %logger{1} - %msg%n"
Loggers:
Root:
level: info
AppenderRef:
- ref: Console
Logger:
- name: com.company.api
level: trace
additivity: false
AppenderRef:
- ref: Console
level: trace
The logging with below code was working perfectly.
#Slf4j
public class LogExample{
public void logMethods(String className,String methodName){
log.trace("{} >> {}", className, methodName);
}
}
But when I upgraded to Spring Boot 1.4.3.RELEASE, the logger is not working.
My new build.gradle after upgrading to 1.4.3 is (just a version change)
version '1.0'
// dependencies for command line
buildscript {
ext {
springBootVersion = '1.4.3.RELEASE'
dependencyManagementVersion = '0.5.2.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: 'spring-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'
}
}
}
dependencies {
/* 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'
// 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}"
/* 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"
}
What thing I'm missing here? TIA
I want to add more details:
there are log4j-api:2.6.2, log4j-core:2.6.2 and log4j-slf4j-impl:2.2.6 on classpath after upgrading to Spring Boot 1.4.3. The thing is appender is not working for trace level because I am getting log for info or above level.

I resolved this problem by moving log4j2.yml directly into resource directory.
Earlier, with Spring Boot 1.3.6, I had put log4j2.yml under resources/logging directory with configuration.yml as
logging:
config: classpath:logging/log4j2.yml
I don't know why it didn't work for 1.4.3.RELEASE.

Related

How to resolve invalid packaging for parent POM, must be "pom" but is "jar"

To resolve spring-framework vulnerability posted by spring.io
I tried upgrading spring-boot version from 2.4.5 to 2.5.12 and with gradle-6.8 version, on running ./gradlew clean build task is failing with error
Invalid packaging for parent POM org.apache.logging.log4j:log4j-api:2.17.2, must be "pom" but is "jar" in org.apache.logging.log4j:log4j-api:2.17.2
The dependency org.springframework.boot:spring-boot-starter-webflux loads the internal dependency log4j-api:2.17.2
How to resolve invalid parent POM packaging for internal dependencies?
build.gradle
buildscript {
ext {
springBootVersion = '2.5.12'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
{
exclude group: 'org.slf4j', module: 'slf4j-ext'
}
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.service'
version = ''
sourceCompatibility = 11
def logbackVersion = '1.2.3'
repositories {
mavenCentral()
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.apache.logging.log4j') {
details.useVersion '2.17.1'
}
}
}
dependencies {
implementation ('org.springframework.boot:spring-boot-starter-webflux')
developmentOnly('org.springframework.boot:spring-boot-devtools')
testImplementation('org.springframework.boot:spring-boot-starter-test')
testImplementation('io.projectreactor:reactor-test')
implementation("ch.qos.logback:logback-core:${logbackVersion}")
implementation("ch.qos.logback:logback-classic:${logbackVersion}")
implementation('org.apache.httpcomponents:httpclient:4.5.11')
implementation('org.apache.commons:commons-collections4:4.4')
implementation("org.springframework.cloud:spring-cloud-vault-config:2.1.3.RELEASE")
implementation("org.springframework.cloud:spring-cloud-vault-config-consul:2.1.3.RELEASE")
implementation group: 'org.springframework.cloud', name: 'spring-cloud-consul-dependencies', version: '1.0.0.RELEASE', ext: 'pom'
implementation('com.amazonaws:aws-java-sdk-sqs:1.11.634')
implementation('org.projectlombok:lombok:1.18.12')
implementation('org.yaml:snakeyaml:1.26')
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
annotationProcessor('org.projectlombok:lombok:1.18.12')
implementation group: 'org.bouncycastle', name: 'bc-fips', version: '1.0.2'
implementation group: 'org.bouncycastle', name: 'bctls-fips', version: '1.0.11'
}
Adding mavenBom spring-cloud-dependencies helped resolve this issue. Suspecting webflux pulled in a transitive dependency to an older release and adding spring-cloud-dependencies bom in dependencyManagement ensured all Spring dependencies are at the same version
Here's update build.gradle file that worked
plugins {
id 'org.springframework.boot' version '2.6.6'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'application'
}
group = 'com.service'
version = '1.0.0-SNAPSHOT'
sourceCompatibility = '11'
application {
mainClass = 'com.service.scheduler.SchedulerApplication'
}
repositories {
mavenCentral()
}
ext {
set('springCloudVersion', "2021.0.1")
set('logbackVersion', "1.2.11")
}
bootJar {
archiveFileName = 'scheduler.jar'
}
bootRun {
systemProperties = System.properties
}
dependencies {
/*---spring dependencies---*/
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.cloud:spring-cloud-starter-vault-config'
implementation 'org.springframework.cloud:spring-cloud-vault-config-consul'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
implementation 'com.amazonaws:aws-java-sdk-sqs:1.12.187'
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
implementation 'org.apache.commons:commons-collections4:4.4'
implementation 'org.yaml:snakeyaml:1.30'
implementation 'com.google.code.gson:gson:2.9.0'
/*---fips dependencies---*/
implementation group: 'org.bouncycastle', name: 'bc-fips', version: '1.0.2'
implementation group: 'org.bouncycastle', name: 'bctls-fips', version: '1.0.11'
/*---lombok dependencies---*/
implementation 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
/*---logback dependencies---*/
implementation("ch.qos.logback:logback-core:${logbackVersion}")
implementation("ch.qos.logback:logback-classic:${logbackVersion}")
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

Why subproject dependency jar includes all dependencies in it?

My project consists of multiple modules like core, my-backend, university, learning, etc.
Core is module which is required in all rest modules.
When I create build of my-backend module, I see core is being added with all dependencies in it which is making that jar too big. Seems some issue with my gradle file which is causing this problem.
Also somehow application.yml from core module is not being loaded from my-backend module. Any Idea why?
My gradle file is as follows:
buildscript {
ext {
springBootVersion = '2.2.1.RELEASE'
internalUrl = 'http://internal/repository'
}
repositories {
mavenLocal()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "http://repo.spring.io/release" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.15'
}
}
plugins {
id "io.freefair.lombok" version "3.8.4" apply false
id 'org.springframework.boot' version '2.2.1.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
}
subprojects {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'application'
apply from: "$rootDir/dependencies.gradle"
mainClassName = "com.myk.MyApp"
group = 'com'
version = app.version
description = """"""
sourceCompatibility = 11
targetCompatibility = 11
ext {
set('springCloudVersion', "Hoxton.RC1")
}
repositories {
mavenLocal()
maven { url "http://repo.spring.io/libs-snapshot" }
jcenter()
mavenCentral()
maven { url "http://repo.maven.apache.org/maven2" }
maven { url "http://maven.aksw.org/repository/internal" }
maven { url "https://dl.bintray.com/michaelklishin/maven/" }
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
// additional plugins
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: "io.freefair.lombok"
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.springframework.boot:spring-boot-starter-aop'
implementation 'org.springframework.boot:spring-boot-starter-integration'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.springframework.cloud:spring-cloud-stream-test-support'
testImplementation (group: 'com.github.javafaker', name: 'javafaker', version: ver.'javafaker') {
exclude group: 'org.yaml', module: 'snakeyaml'
}
}
test {
useJUnitPlatform()
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
}
project(':core') {
dependencies {
implementation group: 'com.github.fommil.netlib', name: 'all', version: '1.1.2' // weka dependency
implementation 'org.springframework.boot:spring-boot-configuration-processor:2.2.1.RELEASE'
implementation group: 'com.google.firebase', name: 'firebase-admin', version: ver.'firebase-admin'
implementation group: 'com.google.apis', name: 'google-api-services-gmail', version: ver.'google-api-services-gmail'
compile "org.quartz-scheduler:quartz:${ver.quartz}"
}
}
[
':university',
':my-backend',
':learning'
].each {
project(it) {
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
apply plugin: 'io.spring.dependency-management'
mainClassName = "com.myk.MyApp"
springBoot {
buildInfo()
}
dependencies {
compile project(':core')
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testCompile group: 'io.github.swagger2markup', name: 'swagger2markup', version: ver.'swagger2markup'
}
}
}

Configure application.properties in spring boot for public url in keycloak

I'm developing spring boot application (v 2.1.0) with keycloak to secure app (v 4.5.0).
I already configured keycloak security in gradle and application.properties.
However keycloak returns unauthorized (401 Error) even for urls which are not added to security constraints.
Gradle and application.properties file are provided following
Gradle
buildscript {
ext.kotlin_version = '1.3.11' // Required for Kotlin integration
ext.spring_boot_version = '2.1.0.RELEASE'
ext.keycloak_version = '4.5.0.Final'
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // Required for Kotlin integration
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version" // See https://kotlinlang.org/docs/reference/compiler-plugins.html#spring-support
classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_version"
}
}
apply plugin: 'kotlin' // Required for Kotlin integration
apply plugin: "kotlin-spring" // https://kotlinlang.org/docs/reference/compiler-plugins.html#spring-support
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
jar {
baseName = 'gs-rest-service'
version = '0.1.0'
}
repositories {
jcenter()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-data-rest')
compile group: 'org.hibernate', name: 'hibernate-envers', version: '5.1.0.Final'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" // Required for Kotlin integration
compile("org.jetbrains.kotlin:kotlin-reflect")
compile "org.springframework.boot:spring-boot-starter-web"
// compile 'org.springframework.boot:spring-boot-starter-security'
//KeyCloak
compile group: 'org.keycloak', name: 'keycloak-spring-boot-starter', version: '4.7.0.Final'
compile group: 'org.keycloak', name: 'keycloak-spring-boot-adapter', version: '4.7.0.Final'
compile "org.keycloak:keycloak-admin-client:$keycloak_version"
//RestEasy
// https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-client
compile group: 'org.jboss.resteasy', name: 'resteasy-client', version: '3.6.2.Final'
// https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs
compile group: 'org.jboss.resteasy', name: 'resteasy-jaxrs', version: '3.6.2.Final'
// https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jackson2-provider
compile group: 'org.jboss.resteasy', name: 'resteasy-jackson2-provider', version: '3.6.2.Final'
// //Oauth2
// // https://mvnrepository.com/artifact/org.springframework.security.oauth/spring-security-oauth2
// compile group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version: '2.3.4.RELEASE'
// https://mvnrepository.com/artifact/org.springframework/spring-jdbc
compile group: 'org.springframework', name: 'spring-jdbc', version: '5.1.0.RELEASE'
// https://mvnrepository.com/artifact/org.postgresql/postgresql
compile group: 'org.postgresql', name: 'postgresql', version: '9.3-1100-jdbc41'
compile group: 'org.postgresql', name: 'postgresql', version: '42.2.5'
testCompile('org.springframework.boot:spring-boot-starter-test')
}
Application.properties
#Server
server.port = 8090
# Database
spring.jpa.database=postgresql
#spring.datasource.platform
spring.jpa.show-sql=false
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/dbname
spring.datasource.username=postgres
spring.datasource.password=123
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
# new
keycloak.realm = realm
keycloak.auth-server-url = http://localhost:8080/auth
keycloak.ssl-required = external
keycloak.resource = client_id
keycloak.credentials.secret = client_secret
keycloak.realm-key=public_key
keycloak.security-constraints[0].auth-roles[0]=USER
keycloak.security-constraints[0].security-collections[0].patterns[0]=/user/*
keycloak.security-constraints[0].security-collections[0].patterns[1]=/createStudent
keycloak.security-constraints[0].auth-roles[1]=admin
keycloak.security-constraints[0].security-collections[1].patterns[0]=/createStudent2
keycloak.security-constraints[0].security-collections[1].patterns[1]=/createRole
keycloak.security-constraints[0].security-collections[1].patterns[2]=/roles
keycloak.security-constraints[0].security-collections[1].patterns[3]=/assignRole
keycloak.security-constraints[0].security-collections[1].patterns[4]=/users
I want login and main page of the app to be public
/login and /home
Thanks in advance!

Gradle Spring Boot: Add folder at root to jar

So I have a folder .ebextensions at the root of my spring boot project,and those files are not being included in my jar when I use "bootpackage" in my gradle plugin for intellij.I am deploying the jar On Amazon Web Services
How do I include these files in my jar?
My build.gradle
buildscript {
ext {
springBootVersion = '1.5.9.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
group = 'haughton.daniel'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
ext {
springCloudVersion = 'Edgware.SR1'
}
dependencies {
//compile 'org.springframework.cloud:spring-cloud-starter-aws'
compile('org.springframework.boot:spring-boot-starter-data-jpa')
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-mail
compile group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version: '2.0.0.RELEASE'
compile('org.springframework.boot:spring-boot-starter-jdbc')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
// https://mvnrepository.com/artifact/org.thymeleaf.extras/thymeleaf-extras-springsecurity4
compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity4', version: '2.1.2.RELEASE'
// https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-aws-autoconfigure
//compile group: 'org.springframework.cloud', name: 'spring-cloud-aws-autoconfigure', version: '1.2.2.RELEASE'
// https://mvnrepository.com/artifact/mysql/mysql-connector-java
// https://mvnrepository.com/artifact/mysql/mysql-connector-java
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.6'
compile('org.springframework.boot:spring-boot-starter-web')
compile ('org.apache.tomcat:tomcat-dbcp:8.0.30')
runtime('mysql:mysql-connector-java')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
Solution:
Added this to my build.gradle
processResources {
from ('.ebextensions/') {
into '.ebextensions'
}
}
I added an ebextensions folder into source of my project, this contains the .ebextensions folder with nginx config:
Folder structure
I extended bootJar task:
bootJar {
baseName = 'project'
version = '1.0.0'
from('ebextensions')
//...
When I run ./gradlew cle ass bootJar, then the unzipped project-1.0.0.jar contains:
.ebextensions
BOOT-INF
META-INF
org
I used Gradle 4.10.
The root cause was 413 Request Entity Too Large with ElasticBeanstalk.
Full content of proxy.conf:
client_max_body_size 20M;

Creating Jar for SpringBoot Application with JSP pages using Gradle

I have an SpringBoot Application which has few JSP pages within it. When I boot the main class from my eclipse it is working perfectly. But at the same time, when I package it as jar, the WEB-INF/jsp folder is not configured properly. I am stuck here. Request your help
Below is my Gradle script
buildscript {
ext {
springBootVersion = '1.5.4.RELEASE'
}
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
group = 'com.arun'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
task packSSO(type: Jar) {
manifest {
attributes(
'Implementation-Title': 'Arun Spring Boot Application',
'Implementation-Version': version,
'Built-By': System.getProperty('user.name'),
'Built-Date': new Date(),
'Main-Class': 'com.arun.MainGate',
'Built-JDK': System.getProperty('java.version')
)
}
sourceSets {
main {
resources {
srcDirs "src/main/resources"
}
}
}
baseName = project.name + '-all'
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
with jar
}
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-tomcat')
compile('org.apache.tomcat.embed:tomcat-embed-jasper')
compile ('javax.servlet:jstl:1.2')
testCompile('org.springframework.boot:spring-boot-starter-test')
testImplementation 'junit:junit:4.12'
}
I exploded the created Jar and the structure looks like below.
so when i run java -jar SSOPage-0.0.1-SNAPSHOT.jar it couldn't find the JSP pages. What exact folder structure should i need to follow and how to package the WEB-INF in gradle ?
I think you must use WAR packaging for a Spring Boot application that uses JSPs. However, you can still use it like a self-contained executable JAR file, as in $ java -jar ./build/libs/hcro-pdi-1.0.0.war.
Here's my build.gradle file from a Spring Boot 2.0.1 project that uses JSPs.
plugins {
id 'org.springframework.boot' version '2.0.1.RELEASE'
id "io.spring.dependency-management" version "1.0.4.RELEASE"
}
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
bootWar {
baseName = 'hcro-pdi'
version = '1.0.0'
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
compile('org.springframework.boot:spring-boot-starter-jdbc')
compile('javax.servlet:jstl')
compile('org.apache.tomcat.embed:tomcat-embed-jasper')
// Devtools enable hot-reloading of JSP and static content
compile("org.springframework.boot:spring-boot-devtools")
compile(group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.2.0')
compile(group: 'org.apache.commons', name: 'commons-lang3', version: '3.7')
compile(group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.5')
compile(group: 'joda-time', name: 'joda-time')
compile(group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-joda')
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
// When running in bootRun task, automatically reload static resources when changed
// https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-gradle-plugin.html#build-tool-plugins-gradle-running-applications
bootRun {
jvmArgs "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
sourceResources sourceSets.main
}
And, you do have to add the two properties to application.properties shared by #Yogi.
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
You need to create application.properties under resources folder in your application and define below properties:
spring.mvc.view.prefix: /WEB-INF/jsp/ (your path for JSP files)
spring.mvc.view.suffix: .jsp
Sample MVC examples:
http://www.springboottutorial.com/creating-web-application-with-spring-boot

Resources