# MapStruct - Java bean mappings, the easy way!
[](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.mapstruct%20AND%20v%3A1.*.Final)
[](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.mapstruct)
* [What is MapStruct?](#what-is-mapstruct)
* [Requirements](#requirements)
* [Using MapStruct](#using-mapstruct)
* [Maven](#maven)
* [Gradle](#gradle)
* [Documentation and getting help](#documentation-and-getting-help)
* [Licensing](#licensing)
* [Building from Source](#building-from-source)
* [Links](#links)
## What is MapStruct?
MapStruct is a Java [annotation processor](http://docs.oracle.com/javase/6/docs/technotes/guides/apt/index.html) for the generation of type-safe and performant mappers for Java bean classes.
To create a mapping between two types, declare a mapper class like this:
```java
@Mapper
public interface CarMapper {
CarMapper INSTANCE = Mappers.getMapper( CarMapper.class );
@Mapping(source = "numberOfSeats", target = "seatCount")
CarDto carToCarDto(Car car);
}
```
At compile time MapStruct will generate an implementation of this interface. The generated implementation uses plain Java method invocations for mapping between source and target objects, i.e. there is no reflection involved. By default, properties are mapped if they have the same name in source and target, but this and many other aspects can be controlled using `@Mapping` and a handful of other annotations.
MapStruct saves you from writing mapping code by hand which is a tedious and error-prone task. The generator comes with sensible defaults and many built-in type conversions, but it steps out of your way when it comes to configuring or implementing special behavior.
Compared to mapping frameworks working at runtime MapStruct offers the following advantages:
* Fast execution by using plain method invocations instead of reflection
* Compile-time type safety: Only objects and attributes mapping to each other can be mapped, no accidental mapping of an order entity into a customer DTO etc.
* Self-contained code, no runtime dependencies
* Clear error-reports at build time if
* mappings are incomplete (not all target properties are mapped)
* mappings are incorrect (cannot find a proper mapping method or type conversion)
* Mapping code is easy to debug (or edited by hand e.g. in case of a bug in the generator)
## Requirements
MapStruct requires Java 1.6 or later.
## Using MapStruct
MapStruct works in command line builds (plain javac, via Maven, Gradle, Ant etc.) and IDEs.
For Eclipse, there is a dedicated plug-in under development (see https://github.com/mapstruct/mapstruct-eclipse) which goes beyond what's possible with an annotation processor, providing content assist for annotation attributes, quick fixes and more.
### Maven
For Maven-based projects add the following to your POM file in order to use MapStruct (the dependencies can be obtained from Maven Central):
```xml
...