2017-03-10 9 views
1

タイトルと同じようにmapstructプロセッサによって生成されないマッパーインターフェイスsrc/test/javaがあります。src/test/javaのMapstructマッパーがMavenビルドで生成されていない

同じプロジェクトでは、src/main/javaのすべてのマッパーが生成されます。これは予想される動作ですか?

テストソース内にマッパーを生成するにはどうすればよいですか?

編集(詳細):

簡体Mavenのモジュール構造:root_project

<build> 
    <pluginManagement> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.6.0</version> 
       <configuration> 
        <source>1.8</source> 
        <target>1.8</target> 
        <annotationProcessorPaths> 
         <path> 
          <groupId>org.mapstruct</groupId> 
          <artifactId>mapstruct-processor</artifactId> 
          <version>1.1.0.Final</version> 
         </path> 
        </annotationProcessorPaths> 
        <compilerArgs> 
         <compilerArg> 
          -Amapstruct.defaultComponentModel=spring 
         </compilerArg> 
        </compilerArgs> 
       </configuration> 
      </plugin> 
      ... 

root_project 
-> module_1 

のpom.xml module_1ののpom.xmlは、基本的に空である:

<dependencies> 

    <dependency> 
     <groupId>org.mapstruct</groupId> 
     <artifactId>mapstruct-jdk8</artifactId> 
     <scope>compile</scope> 
    </dependency> 
+1

? POMなどを共有できますか? – Gunnar

+1

プラグインはPOMのビルド部分でどのように見えますか? pluginManagementの設定はOKです。 – Filip

+1

コンパイルはどのように呼び出されますか? mavenコンパイラプラグインには 'compile'と' testCompile'フェーズがあります。 'mvn compile'だけを実行すると、アプリケーションソースだけがコンパイルされます。 – Filip

答えて

3

私は同じ問題を抱えていて、それをmavenコンパイラプラグインのバージョンを変更して修正しました。 バージョンを注意してください:コンパイラ3.5.1Mapstruct 1.1.0.Finalあなたは注釈プロセッサを設定しましたか

  <!-- compiler plugin --> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.5.1</version> 
       <dependencies> 
        <dependency> 
         <groupId>org.mapstruct</groupId> 
         <artifactId>mapstruct-jdk8</artifactId> 
         <version>1.1.0.Final</version> 
        </dependency> 
       </dependencies> 
       <configuration> 
        <source>1.8</source> 
        <target>1.8</target> 
        <optimize>true</optimize> 
        <annotationProcessorPaths> 
         <path> 
          <groupId>org.mapstruct</groupId> 
          <artifactId>mapstruct-processor</artifactId> 
          <version>1.1.0.Final</version> 
         </path> 
        </annotationProcessorPaths> 
       </configuration> 
      </plugin> 
関連する問題