当我通过命令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一切正常)
链接到github答案 0 :(得分:2)
稍微更新一下:
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}"
}
答案 1 :(得分:0)
最后,我找到了解决方案!我只是在build.gradle中添加它:
plugins {
id 'net.ltgt.apt' version '0.9'
}
apply plugin: 'idea'
apply plugin: "net.ltgt.apt"
问题在于注释处理器(来自mapstruct)