Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何阻止findbugs maven插件验证querydsl生成的类_Java_Maven_Spring Mvc_Findbugs_Querydsl - Fatal编程技术网

Java 如何阻止findbugs maven插件验证querydsl生成的类

Java 如何阻止findbugs maven插件验证querydsl生成的类,java,maven,spring-mvc,findbugs,querydsl,Java,Maven,Spring Mvc,Findbugs,Querydsl,如何配置findbugs maven插件以跳过对Querydsl生成代码的验证? 或 如何配置Querydsl以将QTransactions.java生成到另一个包 运行mvn clean install时,我遇到以下问题: [INFO] --- findbugs-maven-plugin:2.5.2:check (default) @ transactions --- [INFO] BugInstance size is 1 [INFO] Error size is 0 [INFO] Tota

如何配置findbugs maven插件以跳过对Querydsl生成代码的验证? 或 如何配置Querydsl以将QTransactions.java生成到另一个包

运行mvn clean install时,我遇到以下问题:

[INFO] --- findbugs-maven-plugin:2.5.2:check (default) @ transactions ---
[INFO] BugInstance size is 1
[INFO] Error size is 0
[INFO] Total bugs: 1
[INFO] com.example.transactions.QTransaction doesn't override com.mysema.query.types.path.BeanPath.equals(Object) ["com.example.transactions.QTransaction"] At QTransaction.java:[lines 19-53]
[INFO] ------------------------------------------------------------------------
Transactions.java:

package com.example.transactions;

//imports 

@Entity(name="Transaction")
@EntityListeners({TransactionStateListener.class})
public class Transaction {

    @Id
    @GeneratedValue
    @Column(nullable = false)
    protected Long txId;

    @Column(name="txType", nullable=false)
    @Enumerated(EnumType.STRING)
    protected TransactionType type;

    @Column(name="state", nullable=false)
    @Enumerated(EnumType.STRING)
    protected TransactionState state;       

    @Transient
    protected TransactionState oldState;

    @Column(nullable=false, updatable=false)
    protected Long accountId;

    @Column(length=32)  
    protected String productId;

    @Column(length=32)
    protected String externalProductId;

    @Column(length=64)
    protected String externalTxId;

    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    @Column(updatable=false)
    protected DateTime createdDateTime;

    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    @Column(insertable=false)
    protected DateTime lastModifiedDateTime;

    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    @Column(insertable=false)
    protected DateTime executedDateTime;    

    @Version
    protected Integer version;

    @PostPersist
    @PostUpdate
    @PostLoad
    void updateOldState() {
        oldState = state;
    }

    @PrePersist
    void prePersist() throws InvalidTxStateException {
        state = TransactionState.INITIALIZED;
        createdDateTime = DateTime.now();       
    }

    @PreUpdate
    void preUpdate() {      
        lastModifiedDateTime = DateTime.now();
        if (state == TransactionState.EXECUTED) {
            executedDateTime = DateTime.now(); 
        }
    }

    //Getters and setters
}
pom.xml:

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

    ...
    <dependencies>
        <dependency>
            <groupId>com.mysema.querydsl</groupId>
            <artifactId>querydsl-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.mysema.querydsl</groupId>
            <artifactId>querydsl-apt</artifactId>
        </dependency>
        <dependency>
            <groupId>com.mysema.querydsl</groupId>
            <artifactId>querydsl-jpa</artifactId>
        </dependency>
    </dependencies>
    ...

    <build>
         <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <configuration>
                    <onlyAnalyze>com.example.-</onlyAnalyze>
                </configuration>
            </plugin>            
            <plugin>
                <groupId>com.mysema.maven</groupId>
                <artifactId>maven-apt-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <configuration>
<!--                            Specifies the directory in which the query types are generated -->
                            <outputDirectory>target/generated-sources-jpa</outputDirectory>
<!--                            States that the APT code generator should look for JPA annotations -->
                            <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>  
</project>
    ...
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <configuration>
            <failOnError>true</failOnError>
            <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
        </configuration>
    </plugin>
    ...
    <plugin>
        <groupId>com.mysema.maven</groupId>
        <artifactId>maven-apt-plugin</artifactId>
        <executions>
            <execution>
                <phase>generate-sources</phase>
                <goals>
                    <goal>process</goal>
                </goals>
                <configuration>
                   <outputDirectory>target/generated-sources-jpa</outputDirectory>
                   <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                   <options>
                       <querydsl.packageSuffix>.generated</querydsl.packageSuffix>
                   </options>
                </configuration>
            </execution>
        </executions>
    </plugin>
    ...

4.0.0
...
com.mysema.querydsl
querydsl型芯
com.mysema.querydsl
querydsl公寓
com.mysema.querydsl
querydsl jpa
...
maven编译器插件
${java版本}
${java版本}
org.codehaus.mojo
findbugs maven插件
com.example-
com.mysema.maven
maven apt插件
生成源
过程
目标/生成源jpa
com.mysema.query.apt.jpa.JPAAnnotationProcessor

关于第一个问题,我没有答案


您可以通过
querydsl.packageSuffix
APT选项生成子包的Q类,如本文所述

因此,我在环顾四周后找到了解决方案,这要感谢Timos部分解决方案

基本上是两部分

  • 将QueryDSL类生成到另一个包
  • 从findbugs maven插件中排除该包(请参阅)
  • pom.xml:

    <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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
    
        ...
        <dependencies>
            <dependency>
                <groupId>com.mysema.querydsl</groupId>
                <artifactId>querydsl-core</artifactId>
            </dependency>
            <dependency>
                <groupId>com.mysema.querydsl</groupId>
                <artifactId>querydsl-apt</artifactId>
            </dependency>
            <dependency>
                <groupId>com.mysema.querydsl</groupId>
                <artifactId>querydsl-jpa</artifactId>
            </dependency>
        </dependencies>
        ...
    
        <build>
             <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>${java-version}</source>
                        <target>${java-version}</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>findbugs-maven-plugin</artifactId>
                    <configuration>
                        <onlyAnalyze>com.example.-</onlyAnalyze>
                    </configuration>
                </plugin>            
                <plugin>
                    <groupId>com.mysema.maven</groupId>
                    <artifactId>maven-apt-plugin</artifactId>
                    <executions>
                        <execution>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>process</goal>
                            </goals>
                            <configuration>
    <!--                            Specifies the directory in which the query types are generated -->
                                <outputDirectory>target/generated-sources-jpa</outputDirectory>
    <!--                            States that the APT code generator should look for JPA annotations -->
                                <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>  
    </project>
    
        ...
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <configuration>
                <failOnError>true</failOnError>
                <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
            </configuration>
        </plugin>
        ...
        <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>maven-apt-plugin</artifactId>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                       <outputDirectory>target/generated-sources-jpa</outputDirectory>
                       <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                       <options>
                           <querydsl.packageSuffix>.generated</querydsl.packageSuffix>
                       </options>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        ...
    
    。。。
    org.codehaus.mojo
    findbugs maven插件
    真的
    findbugs-exclude.xml
    ...
    com.mysema.maven
    maven apt插件
    生成源
    过程
    目标/生成源jpa
    com.mysema.query.apt.jpa.JPAAnnotationProcessor
    .产生
    ...
    
    findbugs-exclude.xml:

    <FindBugsFilter>
      <Match>
        <Package name="com.example.transactions.generated" />
      </Match>
    </FindBugsFilter>
    
    
    
    谢谢,这帮助我找到了问题的答案。我应该将findbugs-exclude.xml文件放在哪里?我试着把它和家长pom放在同一个文件夹里。但那没用。有什么想法吗?@Chanakaudaya我把indbugs-exclude.xml文件和父pom放在同一个文件夹中,它成功了。因此,您的配置中一定存在一些问题。