how execute and show friendly tests output when running gradle from command line - spring-boot

I can run easily my project tests from IntelliJ IDEA but I am struggling to run them and see the results running from command line.
I read several suggestions around and it seems the trick part is over here
tasks.test {
useJUnitPlatform()
}
tasks.withType<Test> {
this.testLogging {
this.showStandardStreams = true
}
}
As you can see from bellow image all tests are ran and I can see the result in IntelliJ
Neverthelless, when I try from Windows Command Line in same project I get
C:\WSs\KotlinGradleIntelliJ\jokenpo>gradlew test
> Task :test
JokenpoApplicationTests STANDARD_OUT
13:19:28.436 [Test worker] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
13:19:28.452 [Test worker] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
13:19:28.467 [Test worker] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.mycomp.jokenpo.JokenpoApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
13:19:28.483 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither #ContextConfiguration nor #ContextHierarchy found for test class [com.mycomp.jokenpo.JokenpoApplicationTests], using SpringBootContextLoader
13:19:28.498 [Test worker] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.mycomp.jokenpo.JokenpoApplicationTests]: class path resource [com/mycomp/jokenpo/JokenpoApplicationTests-context.xml] does not exist
13:19:28.498 [Test worker] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.mycomp.jokenpo.JokenpoApplicationTests]: class path resource [com/mycomp/jokenpo/JokenpoApplicationTestsContext.groovy] does not exist
13:19:28.498 [Test worker] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.mycomp.jokenpo.JokenpoApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
13:19:28.498 [Test worker] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.mycomp.jokenpo.JokenpoApplicationTests]: JokenpoApplicationTests does not declare any static, non-private, non-final, nested classes annotated with #Configuration.
13:19:28.552 [Test worker] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.mycomp.jokenpo.JokenpoApplicationTests]
13:19:28.621 [Test worker] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [C:\WSs\KotlinGradleIntelliJ\jokenpo\build\classes\kotlin\main\com\mycomp\jokenpo\JokenpoApplication.class]
13:19:28.621 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found #SpringBootConfiguration com.mycomp.jokenpo.JokenpoApplication for test class com.mycomp.jokenpo.JokenpoApplicationTests
13:19:28.738 [Test worker] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - #TestExecutionListeners is not present for class [com.mycomp.jokenpo.JokenpoApplicationTests]: using defaults.
13:19:28.739 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
13:19:28.757 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener#1f9e5479, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener#7f837ef0, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener#75d05b, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener#532b090b, org.springframework.test.context.support.DirtiesContextTestExecutionListener#3efba28b, org.springframework.test.context.transaction.TransactionalTestExecutionListener#5a6b3f5a, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener#7432cb44, org.springframework.test.context.event.EventPublishingTestExecutionListener#7f5ae798, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener#1cd6ed02, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener#1f44802d, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener#7d4e106a, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener#55004e7c, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener#7e951723]
13:19:28.762 [Test worker] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext#7d4abcae testClass = JokenpoApplicationTests, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration#d073212 testClass = JokenpoApplicationTests, locations = '{}', classes = '{class com.mycomp.jokenpo.JokenpoApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=0}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer#4b3fa0b3, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer#1a515c84, [ImportsContextCustomizer#672ec1ca key = [org.springframework.boot.test.autoconfigure.web.servlet.MockMvcAutoConfiguration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebClientAutoConfiguration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebDriverAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcSecurityConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer#51dd20fd, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer#1a85aac8, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer#e2f4006e, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer#9eb94ec], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> false]], class annotated with #DirtiesContext [false] with mode [null].
13:19:28.784 [Test worker] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=0}
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.6.RELEASE)
2020-04-27 13:19:29.222 INFO 13608 --- [ Test worker] c.m.jokenpo.JokenpoApplicationTests : Starting JokenpoApplicationTests on SPANOT149 with PID 13608 (started by Cast in C:\WSs\KotlinGradleIntelliJ\jokenpo)
2020-04-27 13:19:29.222 INFO 13608 --- [ Test worker] c.m.jokenpo.JokenpoApplicationTests : No active profile set, falling back to default profiles: default
2020-04-27 13:19:30.008 INFO 13608 --- [ Test worker] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-04-27 13:19:30.070 INFO 13608 --- [ Test worker] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 64ms. Found 1 JPA repository interfaces.
2020-04-27 13:19:31.402 INFO 13608 --- [ Test worker] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 0 (http)
2020-04-27 13:19:31.424 INFO 13608 --- [ Test worker] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-04-27 13:19:31.424 INFO 13608 --- [ Test worker] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.33]
2020-04-27 13:19:31.595 INFO 13608 --- [ Test worker] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-04-27 13:19:31.595 INFO 13608 --- [ Test worker] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2343 ms
2020-04-27 13:19:31.675 INFO 13608 --- [ Test worker] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-04-27 13:19:31.916 INFO 13608 --- [ Test worker] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-04-27 13:19:31.916 INFO 13608 --- [ Test worker] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:testdb'
2020-04-27 13:19:32.218 INFO 13608 --- [ Test worker] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-04-27 13:19:32.301 INFO 13608 --- [ Test worker] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.12.Final
2020-04-27 13:19:32.382 INFO 13608 --- [ Test worker] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-04-27 13:19:32.533 INFO 13608 --- [ Test worker] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2020-04-27 13:19:33.002 INFO 13608 --- [ Test worker] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-04-27 13:19:33.018 INFO 13608 --- [ Test worker] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default
2020-04-27 13:19:33.202 WARN 13608 --- [ Test worker] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-04-27 13:19:33.487 INFO 13608 --- [ Test worker] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-04-27 13:19:33.836 INFO 13608 --- [ Test worker] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring TestDispatcherServlet ''
2020-04-27 13:19:33.836 INFO 13608 --- [ Test worker] o.s.t.web.servlet.TestDispatcherServlet : Initializing Servlet ''
2020-04-27 13:19:33.851 INFO 13608 --- [ Test worker] o.s.t.web.servlet.TestDispatcherServlet : Completed initialization in 15 ms
2020-04-27 13:19:33.904 INFO 13608 --- [ Test worker] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 56309 (http) with context path ''
2020-04-27 13:19:33.904 INFO 13608 --- [ Test worker] c.m.jokenpo.JokenpoApplicationTests : Started JokenpoApplicationTests in 5.107 seconds (JVM running for 7.245)
UserServiceTest STANDARD_OUT
2020-04-27 13:19:34.605 INFO 13608 --- [ Test worker] .b.t.c.SpringBootTestContextBootstrapper : Neither #ContextConfiguration nor #ContextHierarchy found for test class [com.mycomp.jokenpo.UserServiceTest], using SpringBootContextLoader
2020-04-27 13:19:34.605 INFO 13608 --- [ Test worker] o.s.t.c.support.AbstractContextLoader : Could not detect default resource locations for test class [com.mycomp.jokenpo.UserServiceTest]: no resource found for suffixes {-context.xml, Context.groovy}.
2020-04-27 13:19:34.605 INFO 13608 --- [ Test worker] t.c.s.AnnotationConfigContextLoaderUtils : Could not detect default configuration classes for test class [com.mycomp.jokenpo.UserServiceTest]: UserServiceTest does not declare any static, non-private, non-final, nested classes annotated with #Configuration.
2020-04-27 13:19:34.605 INFO 13608 --- [ Test worker] .b.t.c.SpringBootTestContextBootstrapper : Found #SpringBootConfiguration com.mycomp.jokenpo.JokenpoApplication for test class com.mycomp.jokenpo.UserServiceTest
2020-04-27 13:19:34.605 INFO 13608 --- [ Test worker] .b.t.c.SpringBootTestContextBootstrapper : Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
2020-04-27 13:19:34.605 INFO 13608 --- [ Test worker] .b.t.c.SpringBootTestContextBootstrapper : Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener#2401a061, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener#7ef022b4, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener#5970e47d, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener#3a26795d, org.springframework.test.context.support.DirtiesContextTestExecutionListener#130dd4d0, org.springframework.test.context.transaction.TransactionalTestExecutionListener#6c97b187, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener#321ae364, org.springframework.test.context.event.EventPublishingTestExecutionListener#3bff88eb, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener#46296010, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener#17e3eadb, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener#72872a80, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener#35784ceb, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener#38dc83b4]
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.6.RELEASE)
2020-04-27 13:19:34.653 INFO 13608 --- [ Test worker] com.mycomp.jokenpo.UserServiceTest : Starting UserServiceTest on SPANOT149 with PID 13608 (started by Cast in C:\WSs\KotlinGradleIntelliJ\jokenpo)
2020-04-27 13:19:34.653 INFO 13608 --- [ Test worker] com.mycomp.jokenpo.UserServiceTest : No active profile set, falling back to default profiles: default
2020-04-27 13:19:34.858 INFO 13608 --- [ Test worker] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-04-27 13:19:34.858 INFO 13608 --- [ Test worker] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 13ms. Found 1 JPA repository interfaces.
2020-04-27 13:19:35.005 INFO 13608 --- [ Test worker] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Starting...
2020-04-27 13:19:35.005 INFO 13608 --- [ Test worker] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Start completed.
2020-04-27 13:19:35.037 INFO 13608 --- [ Test worker] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-04-27 13:19:35.037 INFO 13608 --- [ Test worker] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2020-04-27 13:19:35.081 INFO 13608 --- [ Test worker] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-04-27 13:19:35.081 INFO 13608 --- [ Test worker] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-04-27 13:19:35.378 WARN 13608 --- [ Test worker] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-04-27 13:19:35.500 INFO 13608 --- [ Test worker] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-04-27 13:19:35.679 INFO 13608 --- [ Test worker] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:testdb'
2020-04-27 13:19:35.738 INFO 13608 --- [ Test worker] com.mycomp.jokenpo.UserServiceTest : Started UserServiceTest in 1.11 seconds (JVM running for 9.072)
2020-04-27 13:19:35.754 INFO 13608 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-04-27 13:19:35.755 INFO 13608 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-04-27 13:19:35.755 INFO 13608 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-04-27 13:19:35.756 INFO 13608 --- [extShutdownHook] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down'
2020-04-27 13:19:35.756 INFO 13608 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-04-27 13:19:35.756 INFO 13608 --- [extShutdownHook] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down'
2020-04-27 13:19:35.759 INFO 13608 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Shutdown initiated...
2020-04-27 13:19:35.759 INFO 13608 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-04-27 13:19:35.765 INFO 13608 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2020-04-27 13:19:35.765 INFO 13608 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Shutdown completed.
BUILD SUCCESSFUL in 14s
4 actionable tasks: 1 executed, 3 up-to-date
C:\WSs\KotlinGradleIntelliJ\jokenpo>
build.gradle.kts
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.2.6.RELEASE"
id("io.spring.dependency-management") version "1.0.9.RELEASE"
kotlin("jvm") version "1.3.71"
kotlin("plugin.spring") version "1.3.71"
kotlin("plugin.jpa") version "1.3.71"
}
group = "com.mycomp"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
val developmentOnly by configurations.creating
configurations {
runtimeClasspath {
extendsFrom(developmentOnly)
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
developmentOnly("org.springframework.boot:spring-boot-devtools")
runtimeOnly("com.h2database:h2")
//runtimeOnly("org.hsqldb:hsqldb")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
testImplementation ("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<Test> {
this.testLogging {
this.showStandardStreams = true
}
}
Test file
package com.mycomp.jokenpo
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.mycomp.jokenpo.enums.PlayType
import com.mycomp.jokenpo.model.User
import com.mycomp.jokenpo.respository.UserRepository
import com.nhaarman.mockitokotlin2.times
import com.nhaarman.mockitokotlin2.verify
import com.nhaarman.mockitokotlin2.whenever
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.junit.jupiter.MockitoExtension
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.http.MediaType
import org.springframework.test.context.junit.jupiter.SpringExtension
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.get
import org.springframework.test.web.servlet.post
import org.springframework.web.util.NestedServletException
#AutoConfigureMockMvc
#SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
#ExtendWith(SpringExtension::class, MockitoExtension::class)
class JokenpoApplicationTests {
#Autowired
private lateinit var mockMvc: MockMvc
#MockBean
lateinit var respository: UserRepository
#BeforeEach
fun setup() {
whenever(respository.save(User(1, "Test", PlayType.LAGARTO))).thenAnswer {
it.arguments.first()
}
}
#Test
fun `Test createUser in the happy path scenario`() {
val user = User(1, "Test", PlayType.LAGARTO)
mockMvc.post("/users/") {
contentType = MediaType.APPLICATION_JSON
content = jacksonObjectMapper().writeValueAsString(user)
accept = MediaType.APPLICATION_JSON
}.andExpect {
status { isOk }
content { contentType(MediaType.APPLICATION_JSON) }
content { json("""{"id":1,"name":"Test"}""") }
}
//verify(respository, times(1)).save(user)
}
#Test
fun `Test negative scenario of createUser`() {
val user = User(2, "Test", PlayType.LAGARTO)
assertThrows<NestedServletException> {
mockMvc.post("/users/") {
contentType = MediaType.APPLICATION_JSON
content = jacksonObjectMapper().writeValueAsString(user)
accept = MediaType.APPLICATION_JSON
}
}
verify(respository, times(1)).save(user)
}
#Test
fun findUser() {
mockMvc.get("/users?id=99")
.andExpect {
status { isOk }
}
verify(respository, times(1)).findAll()
}
}
PS.: I don't see any change in output if I try "gradle clean test" or point the file with "gradle test --tests JokenpoApplicationTests"
I am confused if my tests are execcuted but I miss some Gradle configutarion to shw the result or even worst my tests aren't executed at all and I lost some basic concept because IntelliJ adds this automatically and "hide" from my eyes

When using the Gradle rich console, test execution is reported in the dynamic part of the Gradle output. This means that once test finishes, that output is gone.
By doing
this.testLogging {
this.showStandardStreams = true
}
you only redirect the test outputs to the console.
Instead, have a look at the TestLoggingContainer documentation and consider logging tests passing and failed with something like:
testLogging {
events "passed", "failed"
}

Related

Spring Batch 5.0 with Spring Boot -- Tasklet job not starting automatically

I have a very simple Spring Boot project with Spring Batch 5.0 and a CommmandLineRunner. There is one Job, one step, and one tasklet that simply prints "Running".
I followed directions and would expect the job to start and complete.
No errors; the Batch database table are being created; the Job and Step beans are being created.
It just doesn't run.
I would be grateful for any insights or assistance!
NOTE: If I launch the job explicitly from the CommandLineRunner using an autowired JobLauncher, it works fine. It just doesn't launch the job automatically (as promised).
NOTE 2: Removing #EnableBatchProcessing makes no difference.
Code follows
application.properties:
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost/postgres
spring.batch.jdbc.initialize-schema=always
spring.batch.job.enabled=true
Application.java:
#SpringBootApplication
#EnableBatchProcessing
public class Application implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
#Override
public void run(String... args) throws Exception {
System.out.println("Starting...");
Thread.sleep(2000);
}
}
Job configuration:
#Configuration
public class AbacusJobConfiguration {
Logger logger = LoggerFactory.getLogger(AbacusJobConfiguration.class);
#Bean
public Step step(JobRepository jobRepository, PlatformTransactionManager transactionManager, Tasklet tasklet1) {
logger.info("Building step");
return new StepBuilder("myTasklet", jobRepository)
.tasklet(tasklet1, transactionManager).allowStartIfComplete(true)
.build();
}
#Bean
public Job job(JobRepository jobRepository, PlatformTransactionManager transactionManager, Step step1) {
return new JobBuilder("myJob", jobRepository)
.incrementer(new RunIdIncrementer())
.start(step1)
.build();
}
#Bean
public MyTasklet myTasklet() {
logger.info("Building tasklet");
var tasklet = new MyTasklet();
return tasklet;
}
}
Tasklet:
public class MyTasklet implements Tasklet {
#Override
public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {
System.out.println("Running MyTasklet");
return RepeatStatus.FINISHED;
}
}
Runtime log:
2023-01-30T10:54:07.407-05:00 INFO 72774 --- [ main] c.optionmetrics.abacuscli.Application : Starting Application using Java 17.0.6 with PID 72774 (/Users/dhait/IdeaProjects/abacus-cli/target/classes started by dhait in /Users/dhait/IdeaProjects/abacus-cli)
2023-01-30T10:54:07.410-05:00 INFO 72774 --- [ main] c.optionmetrics.abacuscli.Application : No active profile set, falling back to 1 default profile: "default"
2023-01-30T10:54:07.626-05:00 INFO 72774 --- [ main] o.s.b.c.c.annotation.BatchRegistrar : Finished Spring Batch infrastructure beans configuration in 2 ms.
2023-01-30T10:54:07.836-05:00 INFO 72774 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2023-01-30T10:54:07.918-05:00 INFO 72774 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection#6ae7deac
2023-01-30T10:54:07.919-05:00 INFO 72774 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2023-01-30T10:54:07.928-05:00 INFO 72774 --- [ main] o.s.b.c.r.s.JobRepositoryFactoryBean : No database type set, using meta data indicating: POSTGRES
2023-01-30T10:54:07.940-05:00 INFO 72774 --- [ main] c.o.abacuscli.AbacusJobConfiguration : Building tasklet
2023-01-30T10:54:07.942-05:00 INFO 72774 --- [ main] c.o.abacuscli.AbacusJobConfiguration : Building step
2023-01-30T10:54:07.954-05:00 INFO 72774 --- [ main] .c.a.BatchObservabilityBeanPostProcessor : No Micrometer observation registry found, defaulting to ObservationRegistry.NOOP
2023-01-30T10:54:07.959-05:00 INFO 72774 --- [ main] .c.a.BatchObservabilityBeanPostProcessor : No Micrometer observation registry found, defaulting to ObservationRegistry.NOOP
2023-01-30T10:54:07.963-05:00 INFO 72774 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : No TaskExecutor has been set, defaulting to synchronous executor.
2023-01-30T10:54:08.040-05:00 INFO 72774 --- [ main] c.optionmetrics.abacuscli.Application : Started Application in 0.882 seconds (process running for 1.246)
Starting...
2023-01-30T10:54:10.050-05:00 INFO 72774 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2023-01-30T10:54:10.054-05:00 INFO 72774 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
With Spring Boot 3, there is no need for #EnableBatchProcessing. If you add it, the auto-configuration of Spring Batch (including the automatic launching of jobs at startup) will back off.
This is mentioned in the migration guide of Spring Boot 3.
EDIT: Not able to reproduce the issue. Things are working as expected with Spring Batch 5 and Spring Boot 3.
$>curl https://start.spring.io/starter.zip -d dependencies=h2,batch -d type=maven-project -o my-batch-job.zip
$>unzip my-batch-job.zip
$> # Paste AbacusJobConfiguration and MyTasklet code in the demo package + add imports
$>./mvnw package
$>./mvnw spring-boot:run
This prints:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.0.2)
2023-01-31T07:48:24.206+01:00 INFO 91983 --- [ main] com.example.demo.DemoApplicationTests : Starting DemoApplicationTests using Java 17.0.4 with PID 91983 (started by mbenhassine in /Users/mbenhassine/Downloads/so75287102)
2023-01-31T07:48:24.207+01:00 INFO 91983 --- [ main] com.example.demo.DemoApplicationTests : No active profile set, falling back to 1 default profile: "default"
2023-01-31T07:48:24.625+01:00 INFO 91983 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2023-01-31T07:48:24.779+01:00 INFO 91983 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection conn0: url=jdbc:h2:mem:0b237f7c-fec8-446f-b2ac-086801ddb7fd user=SA
2023-01-31T07:48:24.780+01:00 INFO 91983 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2023-01-31T07:48:24.858+01:00 INFO 91983 --- [ main] c.example.demo.AbacusJobConfiguration : Building tasklet
2023-01-31T07:48:24.860+01:00 INFO 91983 --- [ main] c.example.demo.AbacusJobConfiguration : Building step
2023-01-31T07:48:24.957+01:00 INFO 91983 --- [ main] com.example.demo.DemoApplicationTests : Started DemoApplicationTests in 0.91 seconds (process running for 1.585)
2023-01-31T07:48:24.958+01:00 INFO 91983 --- [ main] o.s.b.a.b.JobLauncherApplicationRunner : Running default command line with: []
2023-01-31T07:48:24.990+01:00 INFO 91983 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [SimpleJob: [name=myJob]] launched with the following parameters: [{'run.id':'{value=1, type=class java.lang.Long, identifying=true}'}]
2023-01-31T07:48:25.009+01:00 INFO 91983 --- [ main] o.s.batch.core.job.SimpleStepHandler : Executing step: [myTasklet]
Running MyTasklet
2023-01-31T07:48:25.017+01:00 INFO 91983 --- [ main] o.s.batch.core.step.AbstractStep : Step: [myTasklet] executed in 8ms
2023-01-31T07:48:25.025+01:00 INFO 91983 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [SimpleJob: [name=myJob]] completed with the following parameters: [{'run.id':'{value=1, type=class java.lang.Long, identifying=true}'}] and the following status: [COMPLETED] in 23ms
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.556 s - in com.example.demo.DemoApplicationTests
2023-01-31T07:48:25.312+01:00 INFO 91983 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2023-01-31T07:48:25.315+01:00 INFO 91983 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.

Problems trying to work around WebSecurityConfigurerAdapter deprecation using Spring Boot 2.7.5

When updating spring boot version 2.7.5 I noticed that the WebSecurityConfigurerAdapter class was deprecated in this version.
I followed the steps as described in section 2.2 on article on Baeldung
to customize my application's authentication rules, but the filterChain method is not even being called during application startup, as with the "configure" function using spring boot version 2.2.3.
Can anyone help me?
Below I show the before and after of my changes.
Before
#Configuration
#EnableWebSecurity
#EnableGlobalMethodSecurity(prePostEnabled = true)
class SecurityConfiguration : WebSecurityConfigurerAdapter() {
override fun configure(http: HttpSecurity) {
val tokenTypes: List<TokenType> = mapper.readValue(jsonTokenTypes, Array<TokenType>::class.java).toList()
http.csrf().disable()
.authorizeRequests()
.antMatchers("/graphql").permitAll()
.and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.addFilterBefore(
AuthFilter.create(keySet, tokenTypes),
RequestHeaderAuthenticationFilter::class.java
)
}
}
After
#Configuration
#EnableWebSecurity
#EnableGlobalMethodSecurity(prePostEnabled = true)
class SecurityConfiguration() {
#Value("\${vehicle.op.jwk.key-set}")
private lateinit var keySet: List<String>
#Value("\${vehicle.op.jwt.token-types}")
private lateinit var jsonTokenTypes: String
protected val mapper = jacksonObjectMapper()
#Bean
fun filterChain(http: HttpSecurity): SecurityFilterChain {
val tokenTypes: List<TokenType> = mapper.readValue(jsonTokenTypes, Array<TokenType>::class.java).toList()
http.csrf().disable()
.authorizeRequests()
.antMatchers("/graphql").permitAll()
.and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.addFilterBefore(
AuthFilter.create(keySet, tokenTypes),
RequestHeaderAuthenticationFilter::class.java
)
return http.build()
}
Application starts up normally, as shown in the log below:
13:22:33: Executing 'bootRun -Dspring.profiles.active=homolog'...
> Task :checkApolloVersions UP-TO-DATE
> Task :generateMainServiceApolloSources NO-SOURCE
> Task :compileKotlin UP-TO-DATE
> Task :compileJava NO-SOURCE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :bootRunMainClassName UP-TO-DATE
> Task :bootRun __ __ _ _ ___________ | \/ | ___ | |__ (_)___ \ \ \ \ | |\/| |/ _ \| '_ \| | / / \ \ \ \ | | | | (_) | |_) | | / / ) ) ) ) |_| |_|\___/|_.__/|_|/_/ / / / /
===========================/_/_/_/ :: my_application :: (vlatest)
2022-12-06 13:22:37.312 INFO 29076 --- [ main] i.company.op.vehicle.VehicleApplicationKt : Starting VehicleApplicationKt using Java 11.0.16 on DESKTOP-07SSK0A with PID 29076 (C:\company\GitHub\my_application\build\classes\kotlin\main started by admin in C:\company\GitHub\my_application) 2022-12-06 13:22:37.316 INFO 29076 --- [ main] i.company.op.vehicle.VehicleApplicationKt : No active profile set, falling back to 1 default profile: "default" 2022-12-06 13:22:37.816 INFO 29076 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2022-12-06 13:22:37.883 INFO 29076
--- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 62 ms. Found 4 JPA repository interfaces. 2022-12-06 13:22:38.065 INFO 29076 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=c811da27-aff3-39ab-b4ee-d6bb20987e72 2022-12-06 13:22:38.602 INFO 29076 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9090 (http) 2022-12-06 13:22:38.611 INFO 29076 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2022-12-06 13:22:38.612 INFO 29076 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.68] 2022-12-06 13:22:38.718 INFO 29076 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2022-12-06 13:22:38.719 INFO 29076 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1351 ms 2022-12-06 13:22:38.872 INFO 29076 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2022-12-06 13:22:39.037 INFO 29076 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2022-12-06 13:22:39.507 INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor : SELECT COUNT(*) FROM public.liq_db_changelog_lock 2022-12-06 13:22:39.519 INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor : SELECT COUNT(*) FROM public.liq_db_changelog_lock 2022-12-06 13:22:39.520 INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor : SELECT LOCKED FROM public.liq_db_changelog_lock WHERE ID=1 2022-12-06 13:22:39.533 INFO 29076 --- [ main] l.lockservice.StandardLockService : Successfully acquired change log lock 2022-12-06 13:22:39.545 INFO 29076 --- [ main] liquibase.changelog.DatabaseChangeLog : Reading resource: db/changelog/202210050955-changelog.sql 2022-12-06 13:22:39.552 INFO 29076 --- [ main] liquibase.changelog.DatabaseChangeLog : Reading resource: db/changelog/202210051005-changelog.sql 2022-12-06 13:22:39.561 INFO 29076 --- [ main] liquibase.changelog.DatabaseChangeLog : Reading resource: db/changelog/202210141724-changelog.sql 2022-12-06 13:22:39.569 INFO 29076 --- [ main] liquibase.changelog.DatabaseChangeLog : Reading resource: db/changelog/202210310837-changelog.sql 2022-12-06 13:22:39.653 INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor : SELECT MD5SUM FROM public.liq_db_changelog WHERE MD5SUM IS NOT NULL LIMIT 1 2022-12-06 13:22:39.657 INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor : SELECT COUNT(*) FROM public.liq_db_changelog 2022-12-06 13:22:39.659 INFO 29076 --- [ main] l.c.StandardChangeLogHistoryService : Reading from public.liq_db_changelog 2022-12-06 13:22:39.659 INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor : SELECT * FROM public.liq_db_changelog ORDER BY DATEEXECUTED ASC, ORDEREXECUTED ASC 2022-12-06 13:22:39.683 INFO 29076 --- [ main] l.lockservice.StandardLockService : Successfully released change log lock 2022-12-06 13:22:39.831 INFO 29076 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2022-12-06 13:22:39.911 INFO 29076 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.12.Final 2022-12-06 13:22:40.122 INFO 29076 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} 2022-12-06 13:22:40.242 INFO 29076
--- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL9Dialect 2022-12-06 13:22:40.651 INFO 29076 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] 2022-12-06 13:22:40.658 INFO 29076 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2022-12-06 13:22:42.695 INFO 29076 --- [ main] s.b.a.g.s.GraphQlWebMvcAutoConfiguration : GraphQL endpoint HTTP POST /graphql 2022-12-06 13:22:43.217 WARN 29076 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: 6e231318-c400-4c42-bb52-079a429bd04a
This generated password is for development use only. Your security configuration must be updated before running your application in production.
2022-12-06 13:22:43.411 INFO 29076 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter#4e92c6c2, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#71a18feb, org.springframework.security.web.context.SecurityContextPersistenceFilter#26aecf31, org.springframework.security.web.header.HeaderWriterFilter#693f9ab5, org.springframework.security.web.csrf.CsrfFilter#197d6cc9, org.springframework.security.web.authentication.logout.LogoutFilter#286f8e90, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#327fd5c9, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter#3d1b6816, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter#66032b8d, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#70a9f4b7, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#1abacff3, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#4a3d4cd2, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#7c1a5092, org.springframework.security.web.session.SessionManagementFilter#3f04847e, org.springframework.security.web.access.ExceptionTranslationFilter#76e56b17, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#169f4152] 2022-12-06 13:22:43.478 INFO 29076 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9090 (http) with context path '' 2022-12-06 13:22:43.488 INFO 29076
--- [ main] i.company.op.vehicle.VehicleApplicationKt : Started VehicleApplicationKt in 6.557 seconds (JVM running for 6.906)
Originally my application validates only the Bearer Token given in the request header, and after upgrade spring boot version now it requires a user/password authentication.

status:401 unauthorized in postman

Iam working in springboot application and iam trying to save the data in database, code is executing properly and not getting any error during execution but when iam trying to post the url in postman iam getting status: 401 unauthorized
any quick suggestion
console
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.4.RELEASE)
2020-12-08 17:34:07.094 INFO 7236 --- [ main] c.regestration.RegestrationApplication : Starting RegestrationApplication on Darshan with PID 7236 (C:\Users\admin\Desktop\regestration\target\classes started by admin in C:\Users\admin\Desktop\regestration)
2020-12-08 17:34:07.111 INFO 7236 --- [ main] c.regestration.RegestrationApplication : No active profile set, falling back to default profiles: default
2020-12-08 17:34:08.584 INFO 7236 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-12-08 17:34:08.803 INFO 7236 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 202ms. Found 1 JPA repository interfaces.
2020-12-08 17:34:10.751 INFO 7236 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8085 (http)
2020-12-08 17:34:10.788 INFO 7236 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-12-08 17:34:10.788 INFO 7236 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.38]
2020-12-08 17:34:11.158 INFO 7236 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-12-08 17:34:11.158 INFO 7236 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3827 ms
2020-12-08 17:34:11.617 INFO 7236 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-12-08 17:34:11.815 INFO 7236 --- [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-12-08 17:34:11.935 WARN 7236 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-12-08 17:34:12.006 INFO 7236 --- [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.21.Final
2020-12-08 17:34:13.075 INFO 7236 --- [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-12-08 17:34:13.554 INFO 7236 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-12-08 17:34:14.050 INFO 7236 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: 7406d0eb-72dc-4ce4-a8cc-220d3c523098
2020-12-08 17:34:14.273 INFO 7236 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#574cd322, org.springframework.security.web.context.SecurityContextPersistenceFilter#55e2fe3c, org.springframework.security.web.header.HeaderWriterFilter#64f1fd08, org.springframework.security.web.csrf.CsrfFilter#7187bac9, org.springframework.security.web.authentication.logout.LogoutFilter#5c8e67b9, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#1174a305, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter#43e1692f, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter#45c2e0a6, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#1f3165e7, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#12c60152, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#692e028d, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#119c745c, org.springframework.security.web.session.SessionManagementFilter#282ffbf5, org.springframework.security.web.access.ExceptionTranslationFilter#6c15e8c7, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#3a08078c]
2020-12-08 17:34:14.874 INFO 7236 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8085 (http) with context path ''
2020-12-08 17:34:14.884 INFO 7236 --- [ main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
2020-12-08 17:34:14.889 INFO 7236 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-12-08 17:34:14.948 INFO 7236 --- [ task-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2020-12-08 17:34:18.480 INFO 7236 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-12-08 17:34:18.495 INFO 7236 --- [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-12-08 17:34:18.881 INFO 7236 --- [ main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
2020-12-08 17:34:18.890 INFO 7236 --- [ main] c.regestration.RegestrationApplication : Started RegestrationApplication in 13.562 seconds (JVM running for 19.799)
2020-12-08 17:34:42.030 INFO 7236 --- [nio-8085-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-12-08 17:34:42.031 INFO 7236 --- [nio-8085-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-12-08 17:34:42.050 INFO 7236 --- [nio-8085-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 19 ms
controller
package com.regestration.controller;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.regestration.repository.Repository;
import com.regestration.user.User;
#RestController
public class Controller {
#Autowired
Repository repo;
#RequestMapping(value="/saveReg", method= RequestMethod.POST)
public HashMap<String, Object>saveRegestration(#RequestBody User user){
HashMap<String, Object> map = new HashMap<String, Object>();
repo.save(user);
map.put("code", "200");
map.put("code", "saved");
return map;
}
}
application.properties
spring.datasource.url= jdbc:mysql://localhost:3306/myshadi?useSSL=false
spring.datasource.username= root
spring.datasource.password= root
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQL5InnoDBDialect
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto= update
server.port=8085
Spring is activating by default the security.
See line : Using generated security password: 7406d0eb-72dc-4ce4-a8cc-220d3c523098.
You have to inactivate the security if you don't need it : Spring boot Security Disable security

Mapstruct + Lombok with Gradle in Spring Boot (Bean Not Found)

I am trying to use mapstruct with gradle in spring boot project in IntelliJ.
It is not working for any reason.
Here is my build.gradle
plugins {
id 'org.springframework.boot' version '2.3.1.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = JavaVersion.VERSION_14
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
mavenLocal()
}
ext {
mapstructVersion = "1.4.0.Beta2"
lombokVersion = "1.18.12"
}
dependencies {
compileOnly "org.mapstruct:mapstruct:${mapstructVersion}", "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}", "org.projectlombok:lombok:${lombokVersion}"
runtimeOnly'com.h2database:h2'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
compile 'com.h2database:h2:1.4.200'
}
test {
useJUnitPlatform()
}
I have tried this link :https://github.com/mapstruct/mapstruct-examples/blob/master/mapstruct-lombok/build.gradle
from mapstruct-examples
As you may notice that i just took what they had in their examples but it is not working.
I have enableb AnnotationProcessor in IntelliJ as well. Not working.
I have also check if the intellij is building and running with gradle and it does.
Would appreciate for any kind of response.
Thanks in advance.
The Error that i am getting when i try to Run my app*
/Users/fazli/.sdkman/candidates/java/14.0.0.hs-adpt/bin/java -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=50802:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Volumes/Fazli SSD/MapStructExample/build/classes/java/main:/Volumes/Fazli SSD/MapStructExample/build/resources/main:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-data-jpa/2.3.1.RELEASE/5531a4cbd506f13a0b4483ed73c2e75a03d8da46/spring-boot-starter-data-jpa-2.3.1.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-validation/2.3.1.RELEASE/ec99ba85f02b2bec42b84c9c5e74d035ec61109a/spring-boot-starter-validation-2.3.1.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-web/2.3.1.RELEASE/555c4f90141cdbc7637145e413bca0d622ba6796/spring-boot-starter-web-2.3.1.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/com.h2database/h2/1.4.200/f7533fe7cb8e99c87a43d325a77b4b678ad9031a/h2-1.4.200.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.mapstruct/mapstruct/1.4.0.Beta2/4f45905f99bc1edea5910ad7215306cb6338a4bd/mapstruct-1.4.0.Beta2.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.12/48e4e5d60309ebd833bc528dcf77668eab3cd72c/lombok-1.18.12.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-aop/2.3.1.RELEASE/f42e23091d29bde8d1356e45cf13ad32dae51437/spring-boot-starter-aop-2.3.1.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-jdbc/2.3.1.RELEASE/800b64e76588ea88761ad9108cde762204805d66/spring-boot-starter-jdbc-2.3.1.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/jakarta.transaction/jakarta.transaction-api/1.3.3/c4179d48720a1e87202115fbed6089bdc4195405/jakarta.transaction-api-1.3.3.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/jakarta.persistence/jakarta.persistence-api/2.2.3/8f6ea5daedc614f07a3654a455660145286f024e/jakarta.persistence-api-2.2.3.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.hibernate/hibernate-core/5.4.17.Final/3b90ecf6fe93a27a27de9671c9fb25d03ba3def7/hibernate-core-5.4.17.Final.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework.data/spring-data-jpa/2.3.1.RELEASE/1b5e106add569913f0c776aca62f85d8e9ca8cee/spring-data-jpa-2.3.1.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework/spring-aspects/5.2.7.RELEASE/eb48f4ae3e1525179e1ccd10c0e09cfe5c27b8bb/spring-aspects-5.2.7.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter/2.3.1.RELEASE/e0d28696fea064578cb01da346232284f922eba4/spring-boot-starter-2.3.1.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.glassfish/jakarta.el/3.0.3/dab46ee1ee23f7197c13d7c40fce14817c9017df/jakarta.el-3.0.3.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.hibernate.validator/hibernate-validator/6.1.5.Final/e5539b4b05c1520a9b4c0a120fd6e4984a8d5dc8/hibernate-validator-6.1.5.Final.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-json/2.3.1.RELEASE/8342003919c7e5a2470072595ea190cb8a9552c0/spring-boot-starter-json-2.3.1.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-tomcat/2.3.1.RELEASE/5b599d0da04e724479c22daa47f9bfd62533a2e9/spring-boot-starter-tomcat-2.3.1.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework/spring-webmvc/5.2.7.RELEASE/dcd97bcb0a2aa33f272b0031e4771134e327d942/spring-webmvc-5.2.7.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework/spring-web/5.2.7.RELEASE/50a27c77e1731f3b7af5c2ae7caf6fe59bcc309/spring-web-5.2.7.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework/spring-aop/5.2.7.RELEASE/9cf69f8e888091684c05f0a287bb638502e90725/spring-aop-5.2.7.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.aspectj/aspectjweaver/1.9.5/1740dc9140103b796d1722668805fd4cf852780c/aspectjweaver-1.9.5.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework/spring-jdbc/5.2.7.RELEASE/847d31c90479a34e4e1fe7eeeb47ac89adce3438/spring-jdbc-5.2.7.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/com.zaxxer/HikariCP/3.4.5/aa1a2c00aae8e4ba8308e19940711bb9525b103d/HikariCP-3.4.5.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/antlr/antlr/2.7.7/83cd2cd674a217ade95a4bb83a8a14f351f48bd0/antlr-2.7.7.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/net.bytebuddy/byte-buddy/1.10.11/16ac7e0d4afef10ac30db377e8151aff66a90e1c/byte-buddy-1.10.11.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/com.fasterxml/classmate/1.5.1/3fe0bed568c62df5e89f4f174c101eab25345b6c/classmate-1.5.1.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.glassfish.jaxb/jaxb-runtime/2.3.3/c46b68a6e3a2d84ba4eb14c6a8a1a9a7be4048bc/jaxb-runtime-2.3.3.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.hibernate.common/hibernate-commons-annotations/5.1.0.Final/700aeedc4a2089816621948f0379e17cbd17d5db/hibernate-commons-annotations-5.1.0.Final.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.jboss.logging/jboss-logging/3.4.1.Final/40fd4d696c55793e996d1ff3c475833f836c2498/jboss-logging-3.4.1.Final.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.javassist/javassist/3.24.0-GA/d7466fc2e3af7c023e95c510f06448ad29b225b3/javassist-3.24.0-GA.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.jboss/jandex/2.1.3.Final/cd56603e39eb1421560b71daa584348ecfd9e0b8/jandex-2.1.3.Final.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.dom4j/dom4j/2.1.3/a75914155a9f5808963170ec20653668a2ffd2fd/dom4j-2.1.3.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework.data/spring-data-commons/2.3.1.RELEASE/5ae66c24c223315d5b31a45590d293e9145c18e9/spring-data-commons-2.3.1.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/5.2.7.RELEASE/7fd9c4ea311a5d9ab92770be7fc93cc53db334f9/spring-context-5.2.7.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework/spring-orm/5.2.7.RELEASE/32a76d825d8782ff278abe124ded9620444b4a74/spring-orm-5.2.7.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework/spring-tx/5.2.7.RELEASE/66faebf0da41c67b67d082efc98e92c40e83e6b/spring-tx-5.2.7.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/5.2.7.RELEASE/5465ab17688ed62254fdef411cf883fd5c3b77a/spring-beans-5.2.7.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.2.7.RELEASE/56e14a3a5e2813534b5db2da1502cd58ab5bc61d/spring-core-5.2.7.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.30/b5a4b6d16ab13e34a88fae84c35cd5d68cac922c/slf4j-api-1.7.30.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-autoconfigure/2.3.1.RELEASE/6d679d6ba26235a0e81ca1d58f9c1024d9427411/spring-boot-autoconfigure-2.3.1.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/2.3.1.RELEASE/ce8d8b6838ecceb68962b975b18682f4237ccf71/spring-boot-2.3.1.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-logging/2.3.1.RELEASE/3f242a91ffddf7485fde1367e1354c7e13024c8/spring-boot-starter-logging-2.3.1.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/jakarta.annotation/jakarta.annotation-api/1.3.5/59eb84ee0d616332ff44aba065f3888cf002cd2d/jakarta.annotation-api-1.3.5.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.yaml/snakeyaml/1.26/a78a8747147d2c5807683e76ec2b633e95c14fe9/snakeyaml-1.26.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/jakarta.validation/jakarta.validation-api/2.0.2/5eacc6522521f7eacb081f95cee1e231648461e7/jakarta.validation-api-2.0.2.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.11.0/168b2d0e11478b9f0a1bfccd62d6b5e8547b1e6f/jackson-datatype-jsr310-2.11.0.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.11.0/cca91d6375258fd7ff2a6abb7bf91eef492bd606/jackson-datatype-jdk8-2.11.0.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.module/jackson-module-parameter-names/2.11.0/950a1e9a7c1093e7ffd92b216d5a0667f1e39058/jackson-module-parameter-names-2.11.0.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.11.0/8f5aaf3878b0647ff3a16610af53b1a5c05d9f15/jackson-databind-2.11.0.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.apache.tomcat.embed/tomcat-embed-websocket/9.0.36/33fa5038aa66be6e9cc188000c2188aa4dd33c85/tomcat-embed-websocket-9.0.36.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.apache.tomcat.embed/tomcat-embed-core/9.0.36/cf6574dd9c4764e60c548b69da52fc07a5a0a9bd/tomcat-embed-core-9.0.36.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework/spring-expression/5.2.7.RELEASE/c98d7b10f959f9bedfbbbd4d723cf7a1f17a1f71/spring-expression-5.2.7.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.glassfish.jaxb/txw2/2.3.3/12f70b0ea4fc1ad45315e842f63f7c9a46f46530/txw2-2.3.3.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/jakarta.xml.bind/jakarta.xml.bind-api/2.3.3/48e3b9cfc10752fba3521d6511f4165bea951801/jakarta.xml.bind-api-2.3.3.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/com.sun.istack/istack-commons-runtime/3.0.11/4293b5f4e4e89d598f62bb2ba73b32132e7c3a27/istack-commons-runtime-3.0.11.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework/spring-jcl/5.2.7.RELEASE/72282e1f89c58284632220437b5a1e8066c53d7d/spring-jcl-5.2.7.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-to-slf4j/2.13.3/966f6fd1af4959d6b12bfa880121d4a2b164f857/log4j-to-slf4j-2.13.3.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.slf4j/jul-to-slf4j/1.7.30/d58bebff8cbf70ff52b59208586095f467656c30/jul-to-slf4j-1.7.30.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.11.0/c626020ae55d19c690d25cb51c1532ba76e5890f/jackson-annotations-2.11.0.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.11.0/f84302e14648f9f63c0c73951054aeb2ff0b810a/jackson-core-2.11.0.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-api/2.13.3/ec1508160b93d274b1add34419b897bae84c6ca9/log4j-api-2.13.3.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-core/1.2.3/864344400c3d4d92dfeb0a305dc87d953677c03c/logback-core-1.2.3.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-devtools/2.3.1.RELEASE/8f976b7b525d0f0b9c175c2fa5dfe9a07aa48503/spring-boot-devtools-2.3.1.RELEASE.jar:/Users/fazli/.gradle/caches/modules-2/files-2.1/com.sun.activation/jakarta.activation/1.2.2/74548703f9851017ce2f556066659438019e7eb5/jakarta.activation-1.2.2.jar com.example.mapstructexample.MapstructExampleApplication
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.1.RELEASE)
2020-07-16 19:50:22.678 INFO 1742 --- [ restartedMain] c.e.m.MapstructExampleApplication : Starting MapstructExampleApplication on Fazli.local with PID 1742 (/Volumes/Fazli SSD/MapStructExample/build/classes/java/main started by fazli in /Volumes/Fazli SSD/MapStructExample)
2020-07-16 19:50:22.682 INFO 1742 --- [ restartedMain] c.e.m.MapstructExampleApplication : No active profile set, falling back to default profiles: default
2020-07-16 19:50:22.796 INFO 1742 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-07-16 19:50:22.796 INFO 1742 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2020-07-16 19:50:24.915 INFO 1742 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-07-16 19:50:25.108 INFO 1742 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 147ms. Found 1 JPA repository interfaces.
2020-07-16 19:50:26.148 INFO 1742 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-07-16 19:50:26.168 INFO 1742 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-07-16 19:50:26.168 INFO 1742 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.36]
2020-07-16 19:50:26.345 INFO 1742 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-07-16 19:50:26.345 INFO 1742 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3549 ms
2020-07-16 19:50:26.403 INFO 1742 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-07-16 19:50:26.695 INFO 1742 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-07-16 19:50:26.709 INFO 1742 --- [ restartedMain] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:d235bfcc-0a66-46db-9c77-2ec3093f7774'
2020-07-16 19:50:26.941 INFO 1742 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-07-16 19:50:27.070 INFO 1742 --- [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-07-16 19:50:27.078 WARN 1742 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'personController' defined in file [/Volumes/Fazli SSD/MapStructExample/build/classes/java/main/com/example/mapstructexample/web/controller/PersonController.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.mapstructexample.web.mappers.PersonMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2020-07-16 19:50:27.078 INFO 1742 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-07-16 19:50:27.222 INFO 1742 --- [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.17.Final
2020-07-16 19:50:27.597 INFO 1742 --- [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-07-16 19:50:27.884 INFO 1742 --- [ task-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2020-07-16 19:50:29.320 INFO 1742 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-07-16 19:50:29.340 INFO 1742 --- [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-07-16 19:50:29.341 INFO 1742 --- [ restartedMain] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down'
Exception in thread "task-2" org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'springApplicationAdminRegistrar': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:212)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207)
at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:245)
at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:197)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:134)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361)
at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.publishEventIfRequired(DataSourceInitializedPublisher.java:99)
at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.access$100(DataSourceInitializedPublisher.java:50)
at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher$DataSourceSchemaCreatedPublisher.lambda$postProcessEntityManagerFactory$0(DataSourceInitializedPublisher.java:200)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
2020-07-16 19:50:29.356 INFO 1742 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-07-16 19:50:29.590 WARN 1742 --- [ restartedMain] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method failed on bean with name 'inMemoryDatabaseShutdownExecutor': org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-200]
2020-07-16 19:50:29.592 INFO 1742 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-07-16 19:50:29.597 INFO 1742 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2020-07-16 19:50:29.600 INFO 1742 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-07-16 19:50:29.627 INFO 1742 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-16 19:50:29.977 ERROR 1742 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 1 of constructor in com.example.mapstructexample.web.controller.PersonController required a bean of type 'com.example.mapstructexample.web.mappers.PersonMapper' that could not be found.
Action:
Consider defining a bean of type 'com.example.mapstructexample.web.mappers.PersonMapper' in your configuration.
Process finished with exit code 0
#Mapper(uses = {DateMapper.class})
#DecoratedWith(PersonAgeMapper.class)
public interface PersonMapper {
PersonDto toPersonDto(Person person);
Person toPerson(PersonDto dto);
}
You will need to update your mapper to:
#Mapper(uses = {DateMapper.class}, componentModel = "spring")
#DecoratedWith(PersonAgeMapper.class)
public interface PersonMapper {
PersonDto toPersonDto(Person person);
Person toPerson(PersonDto dto);
}
This will tell mapstruct that you are using Spring Boot to control how the beans instantiated and autowired.
More in the mapstruct official docs: https://mapstruct.org/documentation/stable/reference/html/#configuration-options
Alternative 2 :
I added this on my build.gradle and it is working without using: componentModel = "spring"
compileJava {
options.compilerArgs = [
'-Amapstruct.defaultComponentModel=spring'
]
}

Could not autowire service

The below line complaining bean not found.
private CustomUserDetailsService userDetailsService;
I think I've done what I need to do. I add #ComponentScan annotation to the bean and still not working.
Any idea and explanation ? Thanks a lot
SecurityConfiguration.java
// For pre-auth
#EnableGlobalMethodSecurity(prePostEnabled = true)
#EnableWebSecurity
#EnableJpaRepositories(basePackageClasses = UsersRepository.class)
#Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
#Autowired
private CustomUserDetailsService userDetailsService;
......
}
CustomUserDetailsService.java
#ComponentScan
#Service
public class CustomUserDetailsService implements UserDetailsService {
#Autowired
private UsersRepository usersRepository;
#Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
Optional<Users> optionalUsers = usersRepository.findByName(username);
optionalUsers
.orElseThrow(() -> new UsernameNotFoundException("Username not found"));
return optionalUsers
.map(CustomUserDetails::new).get();
}
}
UsersRepository.java
public interface UsersRepository extends JpaRepository<Users, Integer> {
Optional<Users> findByName(String username);
}
Log
17:00:01: Executing task 'bootRun'...
> Task :compileJava
> Task :processResources UP-TO-DATE
> Task :classes
> Task :bootRun
2019-10-13 17:00:03.588 ERROR 69399 --- [ main] o.s.b.c.l.LoggingApplicationListener : Cannot set level 'true' for 'org.hibernate.format_sql'
2019-10-13 17:00:03.591 ERROR 69399 --- [ main] o.s.b.c.l.LoggingApplicationListener : Cannot set level 'true' for 'org.hibernate.use_sql_comments'
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.9.RELEASE)
2019-10-13 17:00:03.690 INFO 69399 --- [ main] dev.house.xproj.XprojApplication : Starting XprojApplication on missions-mbp.lan with PID 69399 (/Users/poc/ workspace/15house-java-backend/build/classes/java/main started by poc in /Users/poc/workspace/15house-java-backend)
2019-10-13 17:00:03.691 INFO 69399 --- [ main] dev.house.xproj.XprojApplication : No active profile set, falling back to default profiles: default
2019-10-13 17:00:04.272 INFO 69399 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-10-13 17:00:04.295 INFO 69399 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 12ms. Found 0 repository interfaces.
2019-10-13 17:00:04.621 INFO 69399 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$3e3b00fc] is not eligible for getting processed by all BeanPostProcessors ( for example: not eligible for auto-proxying)
2019-10-13 17:00:04.884 INFO 69399 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8083 (http)
2019-10-13 17:00:04.910 INFO 69399 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-10-13 17:00:04.910 INFO 69399 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.26]
2019-10-13 17:00:05.021 INFO 69399 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-10-13 17:00:05.021 INFO 69399 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1292 ms
2019-10-13 17:00:05.174 INFO 69399 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-10-13 17:00:05.599 INFO 69399 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-10-13 17:00:05.660 INFO 69399 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-10-13 17:00:05.738 INFO 69399 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.3.12.Final}
2019-10-13 17:00:05.739 INFO 69399 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-10-13 17:00:05.913 INFO 69399 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2019-10-13 17:00:06.059 INFO 69399 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2019-10-13 17:00:06.332 INFO 69399 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-10-13 17:00:06.552 INFO 69399 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-10-13 17:00:06.598 WARN 69399 --- [ main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2019-10-13 17:00:06.867 INFO 69399 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: b3f078a7-2394-4323-96b0-1e54fc210699
2019-10-13 17:00:06.985 INFO 69399 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#31da0434, org.springframework.security.web.context.SecurityContextPersistenceFilter#14b31e37, org.springframework.security.web.header.HeaderWriterFilter#7fd4e815, org.springframework.security.web.csrf.CsrfFilter#3b78c683, org.springframework.security.web.authentication.logout.LogoutFilter#11c78080, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#62c3f556, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter#3086f480, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter#6e24ce51, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#60dc1a4e, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#5c48b72c, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#48cb2d73, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#423ed3b5, org.springframework.security.web.session.SessionManagementFilter#20cdb152, org.springframework.security.web.access.ExceptionTranslationFilter#2eda2062, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#72557746]
2019-10-13 17:00:07.077 INFO 69399 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8083 (http) with context path ''
2019-10-13 17:00:07.080 INFO 69399 --- [ main] dev.house.xproj.XprojApplication : Started XprojApplication in 3.756 seconds (JVM running for 4.113)
Might be u have missed, Include #Entity in User bean.
look here https://www.baeldung.com/jpa-entities

Resources