Generator-jhipster: Running gradle application by IntellIj

Created on 25 Jul 2017  Â·  14Comments  Â·  Source: jhipster/generator-jhipster

Overview of the issue

When I run application (jHipster) by command linie (gradlew) everything is working but when I try run application with IntellIJ (by button). For this same error I can't run unit test in IDE.
My sample project with this error in github: https://github.com/Patresss/jHipster

Motivation for or Use Case

I want to run my application by IntellIj and run unit test

Reproduce the error
2017-07-24 21:43:13.313 DEBUG 4312 --- [  restartedMain] c.e.c.E.p.t.d.S.preferredDivisions       : Close successful.
2017-07-24 21:43:13.493 ERROR 4312 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 1 of constructor in com.patres.timetable.service.DivisionService required a bean of type 'com.patres.timetable.service.mapper.DivisionMapper' that could not be found.


Action:

Consider defining a bean of type 'com.patres.timetable.service.mapper.DivisionMapper' in your configuration.


Process finished with exit code 0
Related issues

https://github.com/jhipster/generator-jhipster/issues/4315
https://github.com/jhipster/generator-jhipster/issues/5748

Suggest a Fix

I thing that is a problem with mapstruct but I have no idea how to fix it.

JHipster Version(s)

4.6.2

JHipster configuration
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.patres.timetable",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "4.6.2",
    "baseName": "Test",
    "packageName": "com.patres.timetable",
    "packageFolder": "com/patres/timetable",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "hibernateCache": "ehcache",
    "clusteredHttpSession": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "postgresql",
    "prodDatabaseType": "postgresql",
    "searchEngine": "elasticsearch",
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "gradle",
    "enableSocialSignIn": false,
    "jwtSecretKey": "18817051906d7b75a7c8c96ac82de44228e55742",
    "clientFramework": "angularX",
    "useSass": true,
    "clientPackageManager": "yarn",
    "applicationType": "monolith",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": [
      "en",
      "pl"
    ]
  }
}
Entity configuration(s) entityName.json files generated in the .jhipster directory
entity Division {
    name String required,
    shortName String,
    numberOfPeople Long,
    colorBackground String,
    colorText String
}

paginate all with pagination
service all with serviceClass

dto * with mapstruct
Browsers and Operating System

Windows 10, Google Chrome

  • [X] Checking this box is mandatory (this is just to show you read everything)

Most helpful comment

Finally, I found a solution! I just add this in my build.gradle:

plugins {
    id 'net.ltgt.apt' version '0.9'
}

apply plugin: 'idea'
apply plugin: "net.ltgt.apt"

The problem was with annotation processors (from mapstruct).

All 14 comments

Have a look in the older tickets, this has already been answered several times.

Yes, I looked in the older tickets but I haven't see a solutions for my problem. I only see solution for maven project, but I use gradle.

Sorry I'm with my phone so it's hard to help: you need to use the "IDE" profile, as mentioned in the docs.
That should be the same for Gradle and Maven.

Thank You, but in documentations I can see only information about IDE profile for Maven:

Configuring your IDE for MapStruct
MapStruct is an annotation processor, and as such it should also be set up to be run automatically when your IDE compiles the project.

If you are using Maven, you need to activate the IDE maven profile in your IDE. Gradle users don’t need to apply anything IDE-specific.

Oh sorry, normally it works the same for both... I can't help you right now, but I'm sure others will!

I am also only on mobile until Sunday but usually idea detects mapstruct or
other annotation processors quite well.

Am 25.07.2017 5:55 nachm. schrieb "Julien Dubois" <[email protected]

:

Oh sorry, normally it works the same for both... I can't help you right
now, but I'm sure others will!

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/jhipster/generator-jhipster/issues/6169#issuecomment-317781010,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAMaiWydG0FPfpzq2FsrVoORCLL5ggGVks5sRhAGgaJpZM4OiiCd
.

Finally, I found a solution! I just add this in my build.gradle:

plugins {
    id 'net.ltgt.apt' version '0.9'
}

apply plugin: 'idea'
apply plugin: "net.ltgt.apt"

The problem was with annotation processors (from mapstruct).

Great. Looks reasonable. Can you do a PR?

apply plugin: 'idea'

Knowing nothing about gradle, I wonder whether this could cause problems to eclipse users

Can't check it right now but usually these plugins are used by the ide
integrations and not part of the default tasks. Don't we have both plugins
already in our config? Idea and eclipse?

Am 26.07.2017 5:52 nachm. schrieb "Gaël Marziou" notifications@github.com:

apply plugin: 'idea'
Knowing nothing about gradle, I wonder whether this could cause problems
to eclipse users

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/jhipster/generator-jhipster/issues/6169#issuecomment-318096960,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAMaiZS86nosi2hGZhbtb5bHxSN_uQydks5sR2C2gaJpZM4OiiCd
.

Adding the idea plugin didn't solve it for me I had to add "net.ltgt.apt-idea" two in the mapstruct.gradle after "net.ltgt.apt"

I have discovered th enew plugin a week ago and tried it with another (simpler project) and it work fine (but still had to tell idea to forward actions to gradle). As the plugin is now compatible with gradle 4.3 I will provide a PR for that. Same for the apt eclpse plugin which automates most of the configuration.

I had this issue recently. We should update our IDEA docs to this. Just adding

apply plugin: 'idea'

fixes the problem

We already add this to the generated code. With the additional apt plugin you don't need to activate annotation processing manually in your ide anymore.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SudharakaP picture SudharakaP  Â·  3Comments

kaidohallik picture kaidohallik  Â·  3Comments

dronavallisaikrishna picture dronavallisaikrishna  Â·  3Comments

lsadehaan picture lsadehaan  Â·  3Comments

marcelinobadin picture marcelinobadin  Â·  3Comments