我创建了一个使用 MongoDB 实现 hibernate OGM 的应用程序。它在 Eclipse 中运行得很好,但是,当我构建一个 fat jar 并尝试运行它时,出现以下错误:Exception in thread "main" org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.ogm.service.impl.OgmConfigurationService] at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) at org.hibernate.ogm.boot.impl.OgmMetadataBuilderInitializer.contribute(OgmMetadataBuilderInitializer.java:28) at org.hibernate.boot.internal.MetadataBuilderImpl.<init>(MetadataBuilderImpl.java:141) at org.hibernate.boot.MetadataSources.getMetadataBuilder(MetadataSources.java:136) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:218)就我而言,我在类路径中拥有所有正确的依赖项。我使用 JDK 11 并使用https://github.com/johnrengelman/shadow编译 fat jar 。这是我的persistence.xml:<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.2" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"> <persistence-unit name="crafting-dead-master-server"> <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider> <properties> <property name="hibernate.ogm.datastore.provider" value="MONGODB" /> <property name="hibernate.ogm.datastore.database" value="crafting-dead-master-server" /> <property name="hibernate.ogm.datastore.create_database" value="true" /> <property name="hibernate.search.default.directory_provider" value="filesystem" /> <property name="hibernate.search.default.indexBase" value="lucene/indexes" /> </properties> </persistence-unit></persistence>
1 回答
慕沐林林
TA贡献2016条经验 获得超9个赞
通过不再使用“fat jar”并将依赖项保留在各自的 jar 中,解决了这个问题。Jar 合并导致服务解析变得复杂,从而产生了UnknownServiceException
.
添加回答
举报
0/150
提交
取消