我是新手,现在进行了大量的研究,但仍然无法开发出有效的Wildfly / Hibernate / MongoDB环境。 到目前为止,这基本上是这样做的:
下一步是编辑pom.xml,jboss-deployment-structure.xml,persistence.xml。这就是麻烦开始的地方。我尝试了不同的条目并得到不同的错误。现在我的配置如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.hibernate.ogm" slot="5.1" services="export" />
<module name="org.hibernate.ogm.mongodb" slot="5.1" services="export" />
</dependencies>
</deployment>
</jboss-deployment-structure>
我看到了这个文件的不同版本,有时使用slot =“main”,有时使用services =“import”。
Persitence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="comic-PU" transaction-type="JTA">
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="jboss.as.jpa.providerModule" value="org.hibernate:5.1"/>
<property name="hibernate.ogm.datastore.provider" value="mongodb"/>
<property name="hibernate.ogm.datastore.database" value="comicDB"/>
<property name="hibernate.ogm.datastore.host" value="localhost"/>
<property name="hibernate.ogm.datastore.port" value="27017"/>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
我很确定这里有些不对劲。在部署项目时,Wildfly尝试读取persistence.xml,然后停留片刻并且:
20:58:33,255 INFO [org.jboss.as.jpa] (MSC service thread 1-6) WFLYJPA0002: Read persistence.xml for comic-PU
21:03:32,767 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) WFLYCTL0348: Timeout after [300] seconds waiting for service container stability. Operation will roll back. Step that first updated the service container was 'deploy' at address '[("deployment" => "MYAPP.war")]'
21:03:32,772 ERROR [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0022: Deploy of deployment "ComicFeeder-1.0.war" was rolled back with no failure message
Pom.xml主要是自动生成的,我添加了
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-mongodb</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-core</artifactId>
<version>5.1.0.Final</version>
</dependency>
<archive>
<manifestEntries>
<mode>development</mode>
<url>${project.url}</url>
<Dependencies>org.hibernate.ogm:5.1 services, org.hibernate.ogm.mongodb:5.1 services</Dependencies>
</manifestEntries>
</archive>
清单条目是否必要?
我得到的错误:
我的错误在哪里?当你用hibernate,wildfly和mongodb开始一个新项目时,你的“工作流程”是什么? 使用Glassfish或任何其他服务器会更容易吗? 我找到的一些教程已经过时或者没有用(对我来说)。