我正在尝试使用maven-processor-plugin生成JPA元模型java文件,并设置我的pom.xml如下所示.
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<!-- source output directory -->
<outputDirectory>${basedir}/src/main/java</outputDirectory>
<processors>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</processors>
<overwrite>true</overwrite>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
实际上,我想生成元模型文件(Entity_.java)到相应实体(Entity.java)的相同包中.因此,我在插件中设置outputDirectory为
<outputDirectory>${basedir}/src/main/java</outputDirectory>
Run Code Online (Sandbox Code Playgroud)
第一次运行是好的,但是从以后执行元模型java文件重新生成时,插件总是会出现关于文件复制的错误.
我的问题是 - 有没有办法配置插件,以便它可以在重新生成过程中覆盖现有的文件?
事实上,要解决
这两个都非常不方便,我希望你们能给我一个合适的解决方案.
我正在尝试实现受 IN 子句限制的搜索功能:
我想实现带有过滤器限制的搜索实现:
@GetMapping("find")
public Page<MerchantUserDTO> getAllBySpecification(
@And({
@Spec(path = "name", spec = LikeIgnoreCase.class),
@Spec(path = "login", spec = LikeIgnoreCase.class),
@Spec(path = "email", spec = LikeIgnoreCase.class),
}) Specification<Users> specification,
@SortDefault(sort = "login", direction = Sort.Direction.DESC) Pageable pageable
) {
return merchantUserService.getAllBySpecification(specification, pageable)
.map(g -> MerchantUserDTO.builder()
.id(g.getId())
.login(g.getLogin())
.build()
);
}
@Override
public Page<Users> getAllBySpecification(Specification<Users> specification, Pageable pageable) {
return dao.findAllByTypeIn(specification, pageable, "MerchantUser");
}
Run Code Online (Sandbox Code Playgroud)
存储库:
@Repository
public interface MerchantUserRepository extends JpaRepository<Users, Integer>, JpaSpecificationExecutor<Users> {
Page<Users> findAllByTypeIn(Pageable page, String... types);
Page<Users> …Run Code Online (Sandbox Code Playgroud)