Mapstruct 与 maven-pom 中的其他注释处理器
Mapstruct together with other annotation-processors in maven-pom
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<artifactId>yyy-data</artifactId>
<name>VS yyy (data)</name>
<parent>
<groupId>de.xxx</groupId>
<artifactId>yyy-server</artifactId>
<version>8.1.0-SNAPSHOT</version>
</parent>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<distribution.outputDirectory>${project.build.directory}/dist</distribution.outputDirectory>
</properties>
<dependencies>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.8</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.8-b01</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.8-b01</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.3.0.Final</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.3.0.Final</version>
</path>
</annotationProcessorPaths>
<annotationProcessors>
<annotationProcessor>de.zzz.annotation.processor.GenerateHibernateTypeForEnumProcessor</annotationProcessor>
<annotationProcessor>de.zzz.annotation.processor.GenerateHibernateTypeForWertelistenProcessor</annotationProcessor>
<annotationProcessor>de.zzz.annotation.processor.BusinessObjectAnnotationProcessor</annotationProcessor>
<annotationProcessor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</annotationProcessor>
</annotationProcessors>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>m2e</id>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
亲爱的,
我需要一些帮助来在我的 project
中实现 mapstruct
。我已经有一些注释处理器需要在 Maven 的 pom.xml
中命名。
Mapstruct
建议在pom.xml中添加annotationProcessorPaths
。似乎不可能在同一个 pom.xml 中同时使用两个注释(annotationProcessorPaths
和 annotationProcessor
)。如果这样做,我会得到错误
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default) on project yyy-data: Compilation failure
[ERROR] Annotation processor 'de.zzz.annotation.processor.GenerateHibernateTypeForEnumProcessor' not found
我确实缩短了 pom。所以依赖项可能比实际需要的多。
提前致谢
奥利弗
您仍然可以使用 annotationProcessor
。您需要在依赖项中添加 mapstruct-processor
,然后在 annotationProcessor
.
中添加 org.mapstruct.ap.MappingProcessor
您看到错误的原因是,当您定义 annotationProcessorPaths
时,maven-compiler-plugin
将仅使用那些来查找注释处理器,而不是您的其他依赖项。
或者,如果您的依赖项,您也可以添加 annotationProcessoPaths
中的所有注释处理器。
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
<artifactId>yyy-data</artifactId>
<name>VS yyy (data)</name>
<parent>
<groupId>de.xxx</groupId>
<artifactId>yyy-server</artifactId>
<version>8.1.0-SNAPSHOT</version>
</parent>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<distribution.outputDirectory>${project.build.directory}/dist</distribution.outputDirectory>
</properties>
<dependencies>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.8</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.8-b01</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.8-b01</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.3.0.Final</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.3.0.Final</version>
</path>
</annotationProcessorPaths>
<annotationProcessors>
<annotationProcessor>de.zzz.annotation.processor.GenerateHibernateTypeForEnumProcessor</annotationProcessor>
<annotationProcessor>de.zzz.annotation.processor.GenerateHibernateTypeForWertelistenProcessor</annotationProcessor>
<annotationProcessor>de.zzz.annotation.processor.BusinessObjectAnnotationProcessor</annotationProcessor>
<annotationProcessor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</annotationProcessor>
</annotationProcessors>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>m2e</id>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
亲爱的,
我需要一些帮助来在我的 project
中实现 mapstruct
。我已经有一些注释处理器需要在 Maven 的 pom.xml
中命名。
Mapstruct
建议在pom.xml中添加annotationProcessorPaths
。似乎不可能在同一个 pom.xml 中同时使用两个注释(annotationProcessorPaths
和 annotationProcessor
)。如果这样做,我会得到错误
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default) on project yyy-data: Compilation failure [ERROR] Annotation processor 'de.zzz.annotation.processor.GenerateHibernateTypeForEnumProcessor' not found
我确实缩短了 pom。所以依赖项可能比实际需要的多。
提前致谢 奥利弗
您仍然可以使用 annotationProcessor
。您需要在依赖项中添加 mapstruct-processor
,然后在 annotationProcessor
.
org.mapstruct.ap.MappingProcessor
您看到错误的原因是,当您定义 annotationProcessorPaths
时,maven-compiler-plugin
将仅使用那些来查找注释处理器,而不是您的其他依赖项。
或者,如果您的依赖项,您也可以添加 annotationProcessoPaths
中的所有注释处理器。