вот сервис
CompanyService
package ru.sergalas.perpay.entities.companies.service;
import org.springframework.stereotype.Service;
import ru.sergalas.perpay.entities.companies.mappers.CompanyMapper;
import ru.sergalas.perpay.entities.companies.repository.CompaniesRepository;
@Service
public class CompaniesService {
private final CompaniesRepository companiesRepository;
private final CompanyMapper companyMapper;
public CompaniesService(CompaniesRepository companiesRepository, CompanyMapper mapper)
{
this.companiesRepository = companiesRepository;
this.companyMapper = mapper;
}
}
вот ComapanyMapper
package ru.sergalas.perpay.entities.companies.mappers;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import ru.sergalas.perpay.entities.companies.dto.CompanyReadDTO;
import ru.sergalas.perpay.entities.companies.dto.CompanyWriteDTO;
import ru.sergalas.perpay.entities.companies.entity.Companies;
import java.util.UUID;
@Mapper(imports = UUID.class)
public interface CompanyMapper {
CompanyReadDTO toDTO(Companies companies);
@Mapping(target="id", source="id", defaultExpression = "java( UUID.randomUUID())")
Companies toEntity(CompanyWriteDTO dto);
}
вот gradle
plugins {
id 'java'
id 'org.springframework.boot' version '2.7.10'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}
apply from: 'version.gradle'
group = 'ru.sergalas'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.liquibase:liquibase-core'
implementation "com.google.code.gson:gson:${versions.gson}"
implementation "io.jsonwebtoken:jjwt-api:${versions.jjwt}"
implementation "org.json:json:${versions.json}"
implementation "org.projectlombok:lombok-mapstruct-binding:${versions.lombokmapstruct}"
compileOnly "org.mapstruct:mapstruct:${versions.mapstruct}"
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'org.postgresql:postgresql'
runtimeOnly "io.jsonwebtoken:jjwt-impl:${versions.jjwtimpl}"
runtimeOnly("io.jsonwebtoken:jjwt-orgjson:${versions.jjwtimpl}") {
exclude group: 'org.json', module: 'json'
}
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor "org.mapstruct:mapstruct-processor:${versions.mapstructProcessor}"
}
tasks.named('test') {
useJUnitPlatform()
}
при сборке проекта получаю ошибку
Parameter 1 of constructor in ru.sergalas.perpay.entities.companies.service.CompaniesService required a bean of type 'ru.sergalas.perpay.entities.companies.mappers.CompanyMapper' that could not be found.