英文:
ORM in deployed WAR file is being ignored
问题
我所使用的设置是,我正在使用Maven构建一个Spring API项目,并生成一个.WAR文件。这个WAR文件正在部署到一个Tomcat服务器上。我的设置在Eclipse中本地工作时没有任何问题,可以调用正确的查询等。然而,当我尝试部署到Tomcat服务器时,出现以下错误:
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property findDetails found for type EmployeeInfo!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:94)
...
我不确定是否缺少了某些必要的连接,或者可能需要进行某些设置。任何帮助都受欢迎 - 我已经包含了尽可能多的相关文件,但如果需要其他内容,请告诉我,我也会上传。
EmployeeInfoRepository
@Repository
public interface EmployeeInfoRepository extends JpaRepository<EmployeeInfo, Integer> {
@Query(nativeQuery = true)
public List<EmployeeInfo> findDetails(@Param("id") String id);
}
orm.xml(请注意,它位于src/main/resources/META-INF/目录下)
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="2.0" xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_2_0.xsd">
<named-native-query name="EmployeeInfo.findDetails" result-class="com.place.thing.model.EmployeeInfo">
<query>SELECT ... </query>
</named-native-query>
</entity-mappings>
EmployeeInfoController
@GetMapping("/intake/{id}")
public ResponseEntity<EmployeeIntakeInfoResponse> getEmployeeInfo(@PathVariable(value = "id") String id) throws ResourceNotFoundException {
List<EmployeeInfo> result = intakeFormRepo.findDetails(id);
if (result.size() != 1) {
throw new ResourceNotFoundException("Error Message Here");
}
return ResponseEntity.ok().body(new EmployeeInfoResponse(result.get(0)));
}
(请注意,上述代码是根据您提供的内容进行的翻译,可能需要根据实际情况进行调整。)
英文:
The setup I have is that I am using Maven to build a Spring API project and generating a .WAR file. This war file is being deployed to a Tomcat server. My setup works locally in Eclipse with no issues or problems, and calls the correct queries/etc. However when I attempt to deploy it to the Tomcat server, I get the following error:
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property findDetails found for type EmployeeInfo!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:94)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:382)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:358)
at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:311)
at java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:324)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:293)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:276)
at org.springframework.data.repository.query.parser.Part.<init>(Part.java:81)
at org.springframework.data.repository.query.parser.PartTree$OrPart.lambda$new$0(PartTree.java:250)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)
at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:251)
at org.springframework.data.repository.query.parser.PartTree$Predicate.lambda$new$0(PartTree.java:380)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)
at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:381)
at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:93)
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:76)
... 96 more
I am not sure if we are missing something required to bridge the connection, or there is maybe a setting that is needed. Any assistance is welcome - I have included as many relevant files as I can think of, but let me know if anything else might be required and I will upload it too.
EmployeeInfoRepository
@Repository
public interface EmployeeInfoRepository extends JpaRepository<EmployeeInfo, Integer> {
@Query(nativeQuery = true)
public List<EmployeeInfo> findDetails(@Param("id") String id);
}
orm.xml (please note, it is located in src/main/resources/META-INF/)
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="2.0" xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_2_0.xsd ">
<named-native-query name="EmployeeInfo.findDetails" result-class="com.place.thing.model.EmployeeInfo">
<query>SELECT ... </query>
</named-native-query>
</entity-mappings>
EmployeeInfoController
@GetMapping("/intake/{id}")
public ResponseEntity<EmployeeIntakeInfoResponse> getEmployeeInfo(@PathVariable(value = "id") String id) throws ResourceNotFoundException {
List<EmployeeInfo> result = intakeFormRepo.findDetails(id);
if (result.size() != 1) {
throw new ResourceNotFoundException("Error Message Here");
}
return ResponseEntity.ok().body(new EmployeeInfoResponse(result.get(0)));
}
专注分享java语言的经验与见解,让所有开发者获益!
评论