Странное исключение только для файлов jar, а не для java-приложения, свойство имеет несвязанный тип и не имеет явной целевой сущности

#java #spring-boot #hibernate #maven #jar

Вопрос:

У меня есть приложение spring boot/data, в котором я использовал отношение @OneToOne поверх общего поля. Код работает нормально, когда я запускаю его через intellij (который запускает код по следующему сценарию).

 java  -XX:TieredStopAtLevel=1 -noverify -Dspring.profiles.active=test -Dspring.output.ansi.enabled=always -javaagent:/home/me/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/211.6693.111/lib/idea_rt.jar=36793:/home/me/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/211.6693.111/bin -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -jar my-project/target/rally-court-web-0.0.1-SNAPSHOT.jar --spring.config.location=my-project/src/main/resources/application-test.yml
 

Но когда я запускаю его, используя следующую команду

 java -jar my-project/target/my-project-0.0.1-SNAPSHOT.jar --spring.config.location=my-project/src/main/resources/application-test.yml
 

Я получаю следующую ошибку.

 [org.springframework.data.web.PageableHandlerMethodArgumentResolver]: Factory method 'pageableResolver' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sortResolver' defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.web.HateoasSortHandlerMethodArgumentResolver]: Factory method 'sortResolver' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositoryRestConfiguration' defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.rest.core.config.RepositoryRestConfiguration]: Factory method 'repositoryRestConfiguration' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositories' defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.repository.support.Repositories]: Factory method 'repositories' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'notificationRepository' defined in com.rallycourt.dao.notification.repository.NotificationRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaMappingContext' while setting bean property 'mappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Property com.rallycourt.dao.notification.model.Notification.notifiedItem has an unbound type and no explicit target entity. Resolve this Generic usage issue or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type
2021-08-02 07:40:24.243  INFO 7 --- [           main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-08-02 07:40:24.243  WARN 7 --- [           main] o.s.b.f.support.DisposableBeanAdapter    : Invocation of destroy method failed on bean with name 'entityManagerFactory': org.hibernate.AnnotationException: Property com.rallycourt.dao.notification.model.Notification.notifiedItem has an unbound type and no explicit target entity. Resolve this Generic usage issue or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type
2021-08-02 07:40:24.243  INFO 7 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
 

Я много искал в сети, и все решения основаны на изменении кода и добавлении @Type или указании типа targetEntityType. Но мой вопрос в том, что происходит на банке, которая заканчивается такой ошибкой.