Я использовал Pageable Repository of JPA для поиска страниц для поиска данных в базе данных, например Page<Member> findAll(Pageable pageable)
Но когда я добавил бы ограничения для поиска страниц, имя функции было бы длиннее, например,
Page<Member> findAllByUserSnContainingIgnoreCaseOr ...
Поэтому я решил добавить спецификацию, чтобы легко добавлять ограничения для предикатов.
Однако я не могу полностью скомпилировать свою работу.
Я пытаюсь Работайте над приложением JPA для создания метамоделей JPA по maven, как показано ниже:
В бэкэнде pom. xml file:
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>3.3.3</version>
<executions>
<execution>
<id>generate-jpa-model</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<processors>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</processors>
<outputDirectory>./target/generated-sources/annotations</outputDirectory>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${hibernate.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>compile-maven-processor</id>
<goals>
<goal>compile</goal>
</goals>
<phase>process-sources</phase>
<configuration>
<includes>
<include>./target/generated-sources/annotations</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
, когда я работаю с mvn clean && mvn --projects backend spring-boot:run
,
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ backend ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 95 source files to ********/backend/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] ************/MemberSpecs.java:[24,42] cannot find symbol
symbol: variable Member_
location: class *************.MemberSpecs
Как мне исправить ошибку компиляции? Я думаю, что IntelliJ IDE не может найти и добавить ресурс ./target/generated-sources/annotations/***
Я нашел ресурсы метамодели, такие как Member _. java в ./target/generated-sources/annotations/***
.