当前位置:网站首页>MapStruct - Consider defining a bean of type in your configuration.
MapStruct - Consider defining a bean of type in your configuration.
2022-07-21 07:22:00 【Sheep yard】
The story background
I've tried it before INSTANCE To use MapStruct, But as a Spring The player , Still used to using Bean The way to inject , So I found that the injection failed !!!
Error message
Consider defining a bean of type in your configuration.
Solution
- In fact, or Maven in Lombok and MapStruct Compatibility problems , The correct configuration scheme is attached below
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.18.RELEASE</version>
<relativePath/>
</parent>
<groupId>com.weink</groupId>
<artifactId>weink-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>weink-server</name>
<description>weink-server</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.4.1.Final</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.4.1.Final</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.luxsun.weink.convert;
import com.luxsun.weink.domain.dto.organ.OrganDTO;
import com.luxsun.weink.domain.po.organ.OrganPO;
import com.luxsun.weink.domain.vo.organ.OrganVO;
import org.mapstruct.Mapper;
/**
* @author Lux Sun
* @date 2022/7/18
*/
@Mapper(componentModel = "spring")
public interface OrganMapper {
OrganPO organDtoToPo(OrganDTO organDto);
OrganDTO organVoToDto(OrganVO OrganVo);
}
/**
* @author Lux Sun
* @date 2022/7/8
*/
@Slf4j
@RestController
@RequestMapping("/organ")
public class OrganController {
@Resource
private OrganService organService;
@Resource
private OrganMapper organMapper;
/**
* New institutions
* @param organVo
*/
@PostMapping
public ResultVO<Object> insertOrgan(@RequestBody OrganVO organVo) {
OrganDTO organDto = organMapper.organVoToDto(organVo);
organService.insertOrgan(organDto);
return ResultVoUtil.buildSuccess();
}
}
边栏推荐
- 2020华为云社区年度技术精选合集,700页+免费下载! | 云享·书库 No.01 期推荐(附免费下载)
- What should EDI prepare for easy docking with Lloyd's Lowe's?
- 动作活体检测能力,构建安全可靠的支付级“刷脸”体验
- Analyzing the internal mechanism and breakthrough path of "Web3 paradox"
- 外设篇:触摸屏
- Golang uses reflection to set items in the structure, JSON data source
- [shutter -- basic component] use of AppBar
- C陷阱与缺陷 第2章 词法“陷阱” 2.3 注意作为语句结束标注的分号
- DeiT:注意力也能蒸馏
- [shutter -- top navigation bar] basic use of tabbarview
猜你喜欢
DeiT:注意力也能蒸馏
C陷阱与缺陷 第1章 词法“陷阱” 1.5 字符与字符串
什么?多商户系统不适配 APP?这不就来了么!
【Flutter -- 基础组件】图片组件 Image & Icon
ECCV 2022 | Kuangshi proposed a semi supervised target detection model, dense teacher, which achieved SOTA performance
外设篇:按键和CPU的中断系统
抽丝剥茧C语言(高阶)文件操作+练习
RKE vs. RKE2:对比两种 Kubernetes 发行版
C陷阱和缺陷 第1章 词法“陷阱” 1.1 =不同于==
Peripherals: ADC
随机推荐
CV (3)- Loss Functions and Optimization
[shutter -- basic component] image & Icon
C陷阱和缺陷 第1章 词法“陷阱” 1.1 =不同于==
Get system information
C和指针 第2章 语法“陷阱” 2.2 运算符的优先级问题
ES6 async 与 await 怎么使用(基础)
A detailed explanation of functions in PostgreSQL is enough - common functions and usage methods
【Flutter -- 基础组件】文本组件 Text & TextStyle & TextSpan
IO advanced advanced IO
外设篇:LCD显示器
Golang uses reflection to set items in the structure, JSON data source
Moco V3: visual self supervision ushers in transformer
thinkphp5.0.24反序列化链子分析
C and pointer Chapter 1 Morphology "trap" 1.2 & and | different from & & and||
深入理解Mysql事务隔离级别与锁机制
利用wget下载文件和网页
MySQL索引的数据结构
C陷阱与缺陷 第2章 语法“陷阱” 2.1 理解函数声明
C traps and defects Chapter 2 lexical "traps" 2.3 pay attention to the semicolon marked as the end of the sentence
C陷阱和缺陷 第0章 导读