io.springfox:springfox-boot-starter:3.0.0 does not work - java

I use openjdk-17 and spring 3 (with jakarta)
I want to use
io.springfox:springfox-boot-starter:3.0.0
As I understood it should work without any configurations.
build.gradle
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.0'
id 'io.spring.dependency-management' version '1.1.0'
id 'org.hibernate.orm' version '6.1.5.Final'
}
group = 'com.corporation'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
//implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.liquibase:liquibase-core'
implementation 'org.hibernate:hibernate-validator:8.0.0.Final'
implementation 'org.springdoc:springdoc-openapi-ui:1.6.13'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
//testImplementation 'org.springframework.security:spring-security-test'
implementation 'org.mapstruct:mapstruct:1.5.3.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.3.Final'
implementation "io.springfox:springfox-boot-starter:3.0.0"
}
tasks.named('test') {
useJUnitPlatform()
}
hibernate {
enhancement {
lazyInitialization true
dirtyTracking true
associationManagement true
}
}
Controller
#RequiredArgsConstructor
#RestController
#RequestMapping("/user")
#Api("asdfasdf")
public class UserController {
private final UserService UserService;
#GetMapping("/{id}")
#ApiOperation("adsfa")
public ResponseEntity<UserDto> getUserById(#PathVariable("id") int id) {
Optional<User> optionalUser = UserService.findById(id);
return optionalUser.map(user -> ResponseEntity.ok(UserMapper.INSTANCE.userToUserDto(user))).orElse(ResponseEntity.status(404).body(null));
}
}
I checked urls:
http://localhost:8080/swagger-ui
http://localhost:8080/swagger-ui/
http://localhost:8080/swagger-ui.html
http://localhost:8080/swagger-ui/index.html
I got 404
I want to get swagger-ui page

Related

#GrpcClient is null spring boot 3

I am making grpc client using net.devh.grpc-client-spring-boot-starter
Client:
#Service
public class SystemService {
#GrpcClient("handyman-client")
StatusServiceGrpc.StatusServiceBlockingStub handymanClient;
public VersionResponse getHandymanVersion() {
return handymanClient.getVersion(Empty.newBuilder().build());
}
}
application.yaml:
grpc:
client:
handyman-client:
address: static://localhost:8080
negotiationType: plaintext
In runtime handymanClient is null. Tried spring boot versions from 3.0.0 to 3.0.2. Lowering the spring boot version to 2.7.0 solves the problem - the client is being created now.
Is there a workaround to make it work on spring boot 3?
build.gradle:
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.0'
id 'io.spring.dependency-management' version '1.1.0'
id "com.google.protobuf" version "0.9.2"
}
group = 'hello.grpc'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation 'javax.annotation:javax.annotation-api:1.3.2'
implementation group: 'net.devh', name: 'grpc-client-spring-boot-starter', version: '2.13.0.RELEASE'
implementation group: 'io.grpc', name: 'grpc-stub', version: '1.53.0'
implementation group: 'io.grpc', name: 'grpc-protobuf', version: '1.53.0'
}
sourceSets {
main {
java {
srcDirs 'build/generated/source/proto/main/grpc'
srcDirs 'build/generated/source/proto/main/java'
}
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:4.0.0-rc-2'
}
plugins {
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.53.0'
}
}
generateProtoTasks {
all()*.plugins {
grpc {}
}
}
}
tasks.named('test') {
useJUnitPlatform()
}
springBoot {
buildInfo()
}

Spring Boot - Gradle - No auto configuration classes found in META-INF/spring.factories

when I start app in idea it works well but when i try to start this app from cmd like java -jar build/libs/dev-0.0.1-SNAPSHOT.jar
i get this error
21:02:06.634 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
this is my build.gradle
/*
* This file was generated by the Gradle 'init' task.
*/
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.6.7"
}
}
plugins {
id 'java'
id 'groovy'
id 'maven-publish'
}
repositories {
mavenLocal()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-security:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-validation:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-web:2.6.7'
implementation 'org.springframework.boot:spring-boot-configuration-processor:2.6.7'
implementation 'org.springframework:spring-aop:5.3.19'
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
testCompileOnly 'org.projectlombok:lombok:1.18.24'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
implementation 'org.mapstruct:mapstruct:1.4.2.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'com.vladmihalcea:hibernate-types-52:2.16.2'
implementation 'org.flywaydb:flyway-core:8.5.10'
runtimeOnly 'org.postgresql:postgresql:42.3.4'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.6.7'
testImplementation 'org.springframework.security:spring-security-test:5.6.3'
testImplementation 'org.codehaus.groovy:groovy-all:3.0.10'
testImplementation 'org.spockframework:spock-core:2.1-groovy-3.0'
testImplementation 'org.spockframework:spock-spring:2.1-groovy-3.0'
testImplementation 'org.testcontainers:spock:1.17.1'
testImplementation "org.testcontainers:postgresql:1.17.1"
}
group = 'com.dev'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
targetCompatibility = '17'
java.sourceCompatibility = JavaVersion.VERSION_17
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
compileJava {
options.compilerArgs += "-Amapstruct.defaultComponentModel=spring"
options.compilerArgs += "-Amapstruct.unmappedTargetPolicy=WARN"
}
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes(
'Main-Class': 'com.dev.DevApplication',
'Class-Path': configurations.runtimeClasspath.files.collect { "lib/$it.name" }.join(' ')
)
}
from{
configurations.runtimeClasspath.collect{ it.isDirectory() ? it : zipTree(it)}
}
}
So i edited build.gradle like this and it is working now
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
id 'java'
id 'groovy'
id 'maven-publish'
id 'org.springframework.boot' version '2.6.7'
}
repositories {
mavenLocal()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-security:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-validation:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-web:2.6.7'
implementation 'org.springframework.boot:spring-boot-configuration-processor:2.6.7'
implementation 'org.springframework:spring-aop:5.3.19'
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
testCompileOnly 'org.projectlombok:lombok:1.18.24'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
implementation 'org.mapstruct:mapstruct:1.4.2.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'com.vladmihalcea:hibernate-types-52:2.16.2'
implementation 'org.flywaydb:flyway-core:8.5.10'
runtimeOnly 'org.postgresql:postgresql:42.3.4'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.6.7'
testImplementation 'org.springframework.security:spring-security-test:5.6.3'
testImplementation 'org.codehaus.groovy:groovy-all:3.0.10'
testImplementation 'org.spockframework:spock-core:2.1-groovy-3.0'
testImplementation 'org.spockframework:spock-spring:2.1-groovy-3.0'
testImplementation 'org.testcontainers:spock:1.17.1'
testImplementation "org.testcontainers:postgresql:1.17.1"
}
group = 'com.dev'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
targetCompatibility = '17'
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
compileJava {
options.compilerArgs += "-Amapstruct.defaultComponentModel=spring"
options.compilerArgs += "-Amapstruct.unmappedTargetPolicy=WARN"
}
jar {
enabled = false
}
springBoot {
mainClass = 'com.dev.DevApplication'
}

gradle build failed with jooq configuration: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

guys.
I'm building a spring boot service. Right now I'm setting it up to query a local MySQL instance with jooq.
However, ./gradlew build gives error Unable to load class 'com.mysql.jdbc.Driver'.
Am I missing anything?
More Info
I'm able to see the com.mysql.jdbc.Driver class in Intellij.
Here is my gradle script.
import nu.studer.gradle.jooq.JooqEdition
plugins {
id 'org.springframework.boot' version '2.6.2'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'nu.studer.jooq' version '3.0.2'
id 'java'
}
if(JavaVersion.current() != JavaVersion.VERSION_11){
throw new GradleException("This build must be run with java 11")
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
repositories {
mavenCentral()
}
group = 'snorlax'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
//create a fat Jar with all dependencies
jar {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
from {
configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
manifest {
attributes "Main-Class": "com.snorlax.userservice.MainApplication"
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
dependencies {
// Spring boot
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// Swagger
implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
// Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// RDS Connection
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'mysql:mysql-connector-java:8.0.27'
implementation 'com.amazonaws.secretsmanager:aws-secretsmanager-jdbc:1.0.6'
// JOOQ
implementation 'org.springframework.boot:spring-boot-starter-jooq:2.6.2'
implementation 'org.jooq:jooq-meta:3.15.5'
implementation 'org.jooq:jooq-codegen:3.15.5'
}
test {
useJUnitPlatform()
}
/************************
jooq code generation
*************************/
import org.jooq.codegen.GenerationTool
import org.jooq.meta.jaxb.*
GenerationTool.generate(new Configuration()
.withJdbc(new Jdbc()
.withDriver('com.mysql.jdbc.Driver')
.withUrl('jdbc:mysql://127.0.0.1:3306/SnorlaxRds')
.withUser('root')
.withPassword('123456'))
.withGenerator(new Generator()
.withDatabase(new Database())
.withGenerate(new Generate()
.withPojos(true)
.withDaos(true))
.withTarget(new Target()
.withPackageName('com.snorlax.userservice')
.withDirectory('src/main/java/jooq'))))
My bad.
I missed the buildscript { } block mentioned here: https://www.jooq.org/doc/latest/manual/code-generation/codegen-gradle.
After adding below section, now my gradle build works.
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'org.jooq:jooq-codegen:3.16.2'
classpath 'mysql:mysql-connector-java:8.0.27'
}
}
Full version
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'org.jooq:jooq-codegen:3.16.2'
classpath 'mysql:mysql-connector-java:8.0.27'
}
}
plugins {
id 'org.springframework.boot' version '2.6.2'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
if(JavaVersion.current() != JavaVersion.VERSION_11){
throw new GradleException("This build must be run with java 11")
}
repositories {
mavenCentral()
}
group = 'snorlax'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
//create a fat Jar with all dependencies
jar {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
from {
configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
manifest {
attributes "Main-Class": "com.snorlax.userservice.MainApplication"
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
dependencies {
// Spring boot
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// Swagger
implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
// Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// RDS Connection
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'mysql:mysql-connector-java:8.0.27'
// AWS secretes manager
implementation 'com.amazonaws.secretsmanager:aws-secretsmanager-jdbc:1.0.6'
// JOOQ
implementation 'org.springframework.boot:spring-boot-starter-jooq'
implementation 'org.jooq:jooq-meta:3.16.2'
compileOnly 'org.jooq:jooq-codegen:3.16.2'
}
test {
useJUnitPlatform()
}
/************************
jooq code generation
*************************/
import org.jooq.codegen.GenerationTool;
import org.jooq.meta.jaxb.*;
task generate {
def outputDirectory = projectDir.toString() + '/src/main/java'
println outputDirectory
def configuration = new Configuration()
.withJdbc(new Jdbc()
.withDriver('com.mysql.cj.jdbc.Driver')
.withUrl('jdbc:mysql://127.0.0.1:3306/snorlaxRds')
.withUser('root')
.withPassword('123456'))
.withGenerator(new Generator()
.withDatabase(new Database().withInputSchema("snorlaxRds"))
.withGenerate(new Generate()
.withPojos(true)
.withDaos(true))
.withTarget(new Target()
.withPackageName('snorlax.userservice.database')
.withDirectory(outputDirectory)));
doLast {
GenerationTool.generate(configuration)
}
}

Java with TestNG lose initialized variable

There is surprising situation, which I can't understand. I have test automation with RestAssured (pet project). I want to prepare RequestSpecification spec variable in #BeforeSuite method, in parent class. Then I want to use spec variable in tests of child class. Here is code of parent class
public class BaseTest {
private String baseUrl = "https://api.thecatapi.com/v1/";
protected RequestSpecification spec;
#BeforeSuite
public void beforeSuite() {
String apiKey = System.getProperty("api_key");
spec = new RequestSpecBuilder()
.setContentType(ContentType.JSON)
.setBaseUri(baseUrl)
.addHeader("x-api-key", apiKey)
.addFilter(new ResponseLoggingFilter())
.addFilter(new RequestLoggingFilter())
.addFilter(new AllureRestAssured())
.build();
}
}
And here is a test in child class'
public class OurLittleTest extends BaseTest {
#Test
public void test() {
//1
String id = Breeds.search(spec, "Scottish Fold").then().extract().body().jsonPath().get("[0].id");
problem is that spec variable in test is null, while I was waiting it won't be null...
Why it happens? Why spec is null ?
I've recordered a screencast where you can see my problem
UPDATE
Everything is fine with Junit 5. The spec variable is not null in child classes anymore. So here are me build.gradle files:
With TestNG:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "io.qameta.allure:allure-gradle:2.8.1"
}
}
plugins {
id 'java'
id 'io.qameta.allure' version '2.8.1'
}
sourceCompatibility = JavaVersion.VERSION_1_8
allure {
configuration = 'testImplementation'
version = '2.7.0'
allureJavaVersion = '2.7.0'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.5'
implementation 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
implementation 'io.rest-assured:rest-assured:4.4.0'
implementation group: 'io.qameta.allure', name: 'allure-rest-assured', version: '2.14.0'
implementation "io.qameta.allure:allure-testng:2.14.0"
testImplementation group: 'org.testng', name: 'testng', version: '7.3.0'
}
test {
useTestNG() {
parallel = 'methods'
threadCount = 2
}
if (project.hasProperty("api_key")) {
systemProperties.put("api_key", "$api_key")
}
}
With Junit 5:
plugins {
id 'io.qameta.allure' version '2.5'
id 'java'
}
allure {
configuration = 'testImplementation'
version = '2.7.0'
useJUnit5 {
version = '2.7.0'
}
}
sourceCompatibility = JavaVersion.VERSION_1_8
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
jcenter()
mavenCentral()
}
dependencies {
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.5'
implementation 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
implementation 'io.rest-assured:rest-assured:4.4.0'
implementation group: 'io.qameta.allure', name: 'allure-rest-assured', version: '2.14.0'
implementation group: 'io.qameta.allure', name: 'allure-junit5', version: '2.14.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.2.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.2.0'
}
test {
useJUnitPlatform{
systemProperty 'junit.jupiter.testinstance.lifecycle.default' , 'per_class'
systemProperty 'junit.jupiter.execution.parallel.enabled', 'true'
systemProperty 'junit.jupiter.execution.parallel.mode.default', 'same_thread'
systemProperty 'junit.jupiter.execution.parallel.mode.classes.default', 'concurrent'
}
if (project.hasProperty("api_key")) {
systemProperties.put("api_key", "$api_key")
}
}
What's wrong with TestNG ?
The problem is usage of #BeforeSuite. It is meant to be used only once per suite and ignored in following runs.
For initializing the spec you can either do it directly inline in the field like protected RequestSpecification spec = new RequestSpecBuilder()... or use #BeforeClass.
I tested your code, no error. The problem might be in OurLittleTest class you use Junit, and you use testNG in BaseTest class

Gradle when run with bootRun generate can't find symbol isEmpty

I'm using Gradle to compile project, when I run it with bootRun it output the following error:
can't find symbol isEmpty, that's a lot of them, I knew that's something with the java version, but I don't know how to correct them, it's a shame they don't allow short version post.
Here is my gradle config:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id 'org.springframework.boot' version '2.2.0.M5'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
id 'net.ltgt.apt' version '0.20'
}
apply plugin: 'net.ltgt.apt-idea'
apply plugin: 'kotlin'
apply plugin: 'net.ltgt.apt-eclipse'
group = 'com.fanjiu'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
mapstruct
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
}
ext {
set('springCloudVersion', "Hoxton.M2")
generatedMapperSourcesDir = "${buildDir}/generated-src/mapstruct/main"
}
sourceSets.main {
ext.originalJavaSrcDirs = java.srcDirs
java.srcDir "${generatedMapperSourcesDir}"
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-batch'
implementation 'org.springframework.boot:spring-boot-starter-cloud-connectors'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation('com.github.binarywang:wx-java-miniapp-spring-boot-starter:3.5.0')
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-security")
compile('org.modelmapper:modelmapper:2.3.5')
implementation 'org.springframework.cloud:spring-cloud-starter'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'mysql:mysql-connector-java'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
implementation "org.mapstruct:mapstruct"
annotationProcessor "org.mapstruct:mapstruct-processor"
compileOnly 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
compile 'org.mapstruct:mapstruct:1.3.0.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.3.0.Final'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile 'com.qiniu:qiniu-java-sdk:7.2.+'
compile 'com.alibaba:fastjson:1.2.61'
compile group: 'org.ocpsoft.prettytime', name: 'prettytime', version: '4.0.2.Final'
compile group: 'org.ocpsoft.prettytime', name: 'prettytime-nlp', version: '4.0.2.Final'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
test {
useJUnitPlatform()
}
task generateMainMapperClasses(type: JavaCompile) {
ext.aptDumpDir = file( "${buildDir}/tmp/apt/mapstruct" )
destinationDir = ext.aptDumpDir
classpath = compileJava.classpath + configurations.mapstruct
source = sourceSets.main.originalJavaSrcDirs
ext.sourceDestDir = file ( "$generatedMapperSourcesDir" )
options.define(
compilerArgs: [
"-nowarn",
"-proc:only",
"-encoding", "UTF-8",
"-processor", "org.mapstruct.ap.MappingProcessor",
"-s", ext.sourceDestDir.absolutePath,
"-source", rootProject.sourceCompatibility,
"-target", rootProject.sourceCompatibility,
]
);
inputs.dir source
outputs.dir generatedMapperSourcesDir;
doFirst {
ext.sourceDestDir.mkdirs()
}
doLast {
ext.aptDumpDir.delete()
}
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
//compileJava.dependsOn generateMainMapperClasses
Yes. JDK version, upgrade JDK version solve the problem. And update the file with sourceCompatibility = '13'

Categories