Closed nadjin closed 6 years ago
How is your IntelliJ configured? Are you delegating the build to gradle or not?
@filiphr yes. the project has builded by gradle, InteliJ has installed mapstrcut support plugin. i have no idea now. help me~~
same problem .
java.lang.ClassNotFoundException: Cannot find implementation for org.mapstruct.example.SourceTargetMapper
@filiphr this is my config.
Add sourceSets in build.gradle, it works.
sourceSets {
main.java.srcDirs += "build/generated/source/apt/main"
}
@VictorChow @nadjin How do you solve this problem? I can now generate the implementation class, but I always prompt when injecting objects. java.lang.ClassNotFoundException: Cannot find implementation
@ft0907 add generated folder into sourceSets
@VictorChow Thank you very much for your answer, but I do not have this folder path.
I have generated class and corresponding java files in the /build/classes folder. Is there a problem with the path to generate files?
@ft0907
@VictorChow Thank U so much, I did but it doesn't work.. o( ̄┰ ̄*)ゞ `plugins { id 'java' id 'net.ltgt.apt' version '0.9' } apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'org.springframework.boot'
dependencies { compile('org.springframework.boot:spring-boot-starter-web') compileOnly 'org.mapstruct:mapstruct-jdk8:1.2.0.Final', 'org.projectlombok:lombok:1.+' apt 'org.mapstruct:mapstruct-processor:1.2.0.Final', 'org.projectlombok:lombok:1.+' }
sourceSets { main.java.srcDirs += "build/generated/source/apt/main" } `
@nadjin i use gradle-4.10-all
@VictorChow Thank u. @filiphr VictorChow show the path , you can do like this
then add
sourceSets {
main.java.srcDirs += "build/generated/source/apt/main"
}
in build.gradle
i will try other way .
dependencies { classpath "net.ltgt.gradle:gradle-apt-plugin:0.18" } apply plugin: "net.ltgt.apt-eclipse" compile 'org.mapstruct:mapstruct-jdk8:1.3.0.Beta1' compile 'org.mapstruct:mapstruct-processor:1.3.0.Beta1'
//If you add this line to annotate gradle build, you will make a mistake. annotationProcessor 'org.mapstruct:mapstruct-processor:1.3.0.Beta1'
This is my configuration in gradle. But I configure it to generate build/generated/source/apt.....XxImpl However, class executable files cannot be generated in the running directory. The STS editor I used I guess it should have something to do with my gradle-apt-plugin. Can you generate class files and run successfully? @nadjin @VictorChow
It has been able to run normally, but it is actually a version of Lombok.
dependencies { classpath 'io.franzbecker:gradle-lombok:1.11' classpath "net.ltgt.gradle:gradle-apt-plugin:0.18" } apply plugin: "net.ltgt.apt-eclipse" apply plugin: 'io.franzbecker.gradle-lombok'
lombok { version = '1.18.0' }
dependencies { compileOnly 'org.projectlombok:lombok' compile 'org.mapstruct:mapstruct-jdk8:1.3.0.Beta1' annotationProcessor 'org.mapstruct:mapstruct-processor:1.3.0.Beta1' annotationProcessor 'org.projectlombok:lombok' }
sourceSets { main.java.srcDirs += "build/generated/source/apt/main" }
It's similar to the @filiphr example, but requires additional configuration of sourceSets. Is there anywhere you can configure this path by default!!!
In order for IntelliJ to be properly configured one needs to use the following plugin:
apply plugin: "net.ltgt.apt-idea"
You are all using the gradle-apt-plugin. I think that once you have this IntelliJ should be able to configure itself correctly.
Add sourceSets in build.gradle, it works.
sourceSets { main.java.srcDirs += "build/generated/source/apt/main" }
@VictorChow I added this but still, getting the same error. I'm using gradle 3.4 version
my project uses this path, I using the now configuration for 1.3.1.Final guide:
sourceSets {
main.java.srcDirs += "build/generated/sources/annotationProcessor/java/main"
}
Now it works fine! Thanks!
any ideas for maven ?
Following things worked for me in addition to sourceSet changes:
@Mapper(componentModel = "jsr330")
Add componentModel for Mapper class
IDE : intelij 2018.2 demo : mapstruct-on-gradle run result : Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: Cannot find implementation for org.mapstruct.example.SourceTargetMapper why?