如何配置findbugs-maven-plugin以跳过验证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>
最佳答案 对于第一个问题,我没有答案.
您可以通过querydsl.packageSuffix APT选项生成Q-classes到子包,如此处所述http://www.querydsl.com/static/querydsl/3.2.3/reference/html/ch03s03.html#d0e1847