【问题标题】:Running gradle application by IntellIj通过 IntellIj 运行 gradle 应用程序
【发布时间】:2017-07-24 19:47:22
【问题描述】:

当我通过命令 linie (gradlew) 运行应用程序 (jHipster) 时,一切正常,但是当我尝试使用 IntellIJ 运行应用程序时(通过按钮)

我有一个错误:

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

我所有的课程都是由 jHipster 生成的。例如 DivisionMapper 看起来像这样:

@Mapper(componentModel = "spring", uses = {UserMapper.class, TeacherMapper.class, SubjectMapper.class, })
public interface DivisionMapper extends EntityMapper <DivisionDTO, Division> {

    @Mapping(target = "timetables", ignore = true)
    @Mapping(target = "divisionPlaces", ignore = true)
    @Mapping(target = "divisionTeachers", ignore = true)
    @Mapping(target = "divisionSubjects", ignore = true)
    @Mapping(target = "divisionLessons", ignore = true)
    @Mapping(target = "divisionPeriods", ignore = true)
    @Mapping(target = "divisionProperties", ignore = true)
    @Mapping(target = "preferredPlaces", ignore = true)
    Division toEntity(DivisionDTO divisionDTO); 
    default Division fromId(Long id) {
        if (id == null) {
            return null;
        }
        Division division = new Division();
        division.setId(id);
        return division;
    }
}

谁能给我解释一下?对于同样的错误,我无法在 IDE 中运行单元测试

逐步重现问题:

1) 生成 jhipster 应用:

{
  "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"
    ]
  }
}

2) 生成简单的实体

entity Division {
    name String required,
    shortName String,
    numberOfPeople Long,
    colorBackground String,
    colorText String
}

paginate all with pagination
service all with serviceClass

dto * with mapstruct

3) 在 application-dev.yml 中配置数据库

4) 在 IntellIJ 中运行时出错(但使用命令行 gradlew 一切正常)

5) 使用此示例链接到 github https://github.com/Patresss/jHipster

【问题讨论】:

  • 你能打开运行配置并截取配置的屏幕截图吗?

标签: java spring intellij-idea jhipster


【解决方案1】:

只是一点点更新:

plugins {
    id 'net.ltgt.apt-idea' version '0.13'
}

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

dependencies {
    apt "org.mapstruct:mapstruct-processor:${mapstruct_version}"
    apt "org.hibernate:hibernate-jpamodelgen:${hibernate_version}"
}

【讨论】:

    【解决方案2】:

    终于,我找到了解决办法!我只是将它添加到我的 build.gradle 中:

    plugins {
        id 'net.ltgt.apt' version '0.9'
    }
    
    apply plugin: 'idea'
    apply plugin: "net.ltgt.apt"
    

    问题出在注释处理器(来自 mapstruct)

    【讨论】:

      猜你喜欢
      • 2021-12-11
      • 2019-06-06
      • 2013-05-22
      • 2022-11-23
      • 2018-01-25
      • 1970-01-01
      • 2022-01-09
      • 2014-12-21
      • 2013-02-09
      相关资源
      最近更新 更多