gpt4 book ai didi

java - 如何阻止 findbugs-maven-plugin 验证 querydsl 生成的类

转载 作者:搜寻专家 更新时间:2023-11-01 03:24:12 28 4
gpt4 key购买 nike

我如何配置 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] ------------------------------------------------------------------------

交易.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 类以进行分包,如此处所述 http://www.querydsl.com/static/querydsl/3.2.3/reference/html/ch03s03.html#d0e1847

关于java - 如何阻止 findbugs-maven-plugin 验证 querydsl 生成的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19521508/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com