前两个级别被正确触发(速度违规。事实1.car.vrp(空指针异常,vrp为空)),但随后出现空指针异常。
我不明白为什么。
代码:
@Document(collection = "speed_violation")
@Getter
@Setter
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SpeedViolation {
...
@NotNull
@QueryEmbedded
@QueryInit("*.*")
protected Fact fact1;
...
类事实:
@Data
@EqualsAndHashCode(of = "id")
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Fact {
...
@QueryEmbedded
private Car car;
...
}
级别车:
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Car {
@QueryEmbedded
private Vrp vrp;
}
Vrp类:
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(of = "number")
@Builder
public class Vrp {
@NotNull
private String number;
}
我尝试使用方法:
@Override
public Optional<SpeedViolation> findPendingForFactViolation(String vrp,
Long complexId,
Long camera2Id,
LocalDateTime secondFactPhotoDate,
LocalDateTime maxFirstFactPhotoDate,
LocalDateTime minFirstFactPhotoDate) {
QSpeedViolation speedViolation = QSpeedViolation.speedViolation;
Predicate predicate = speedViolation.fact1.car.vrp`(NullPointerException)`.number.eq(vrp)
...
}
这发生在我从java 8切换到java 11的时候。如果设置jdk 8,一切都工作正常。
pom.xml:
<properties>
<!-- Build properties -->
<maven.version>3.3.9</maven.version>
<java.version>11</java.version>
<shedlock.version>3.0.0</shedlock.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
<minio.version>7.0.2</minio.version>
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<argLine>-Djava.security.egd=file:/dev/./urandom -Xmx512m</argLine>
<m2e.apt.activation>jdt_apt</m2e.apt.activation>
<run.addResources>false</run.addResources>
<!-- These remain empty unless the corresponding profile is active -->
<profile.swagger />
<profile.tls />
<!-- Dependency versions -->
<jhipster-dependencies.version>3.0.3</jhipster-dependencies.version>
<!-- The spring-boot version should match the one managed by
https://mvnrepository.com/artifact/io.github.jhipster/jhipster-dependencies/${jhipster-dependencies.version} -->
<spring-boot.version>2.1.6.RELEASE</spring-boot.version>
<mapstruct.version>1.4.1.Final</mapstruct.version>
<pact.version>3.6.13</pact.version>
<querydsl.version>4.2.2</querydsl.version>
<lombok.version>1.18.16</lombok.version>
<image-utils.version>2.1.0</image-utils.version>
<apache-commons-text.version>1.9</apache-commons-text.version>
<testcontainers.version>1.16.0</testcontainers.version>
<mongock.version>3.3.2</mongock.version>
<!-- Plugin versions -->
<maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-enforcer-plugin.version>3.0.0-M1</maven-enforcer-plugin.version>
<maven-failsafe-plugin.version>3.0.0-M3</maven-failsafe-plugin.version>
<maven-surefire-plugin.version>3.0.0-M3</maven-surefire-plugin.version>
<maven-idea-plugin.version>2.2.1</maven-idea-plugin.version>
<maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
<git-commit-id-plugin.version>2.2.6</git-commit-id-plugin.version>
<lifecycle-mapping.version>1.0.0</lifecycle-mapping.version>
<jsr305.version>3.0.2</jsr305.version>
<influxdb-client.version>2.14</influxdb-client.version>
<junit.utReportFolder>${project.testresult.directory}/test</junit.utReportFolder>
<junit.itReportFolder>${project.testresult.directory}/integrationTest</junit.itReportFolder>
<junit.jupiter.version>5.7.0</junit.jupiter.version>
<mongodb-driver.version>3.10.0</mongodb-driver.version>
<!-- jhipster-needle-maven-property -->
</properties>
...
<dependencies>
<!-- Транзакции -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>${mongodb-driver.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>2.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-mongodb</artifactId>
<version>${querydsl.version}</version>
</dependency>
...
</dependencies>
...
<build>
<defaultGoal>spring-boot:run</defaultGoal>
<plugins>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>
org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor
</processor>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${spring-boot.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
<!-- For JPA static metamodel generation -->
<path>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.4.15.Final</version>
</path>
<!-- jhipster-needle-maven-add-annotation-processor -->
</annotationProcessorPaths>
</configuration>
</plugin>
...
1条答案
按热度按时间wyyhbhjk1#
Querydsl 4.x不支持Java 11。对于Java 11,请升级到Querydsl 5。