我正在尝试在更改 persistence.xml 后部署我的应用程序,但我收到了与我的持久性相关的错误。
我在 HAL 管理控制台中测试连接到我的 MySQL 数据库,测试成功。
坚持:
<?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="itcmedbr_PU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:MySqlDS</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="jakarta.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="jakarta.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/db_medical?zeroDateTimeBehavior=CONVERT_TO_NULL"/>
<property name="jakarta.persistence.jdbc.user" value="root"/>
<property name="jakarta.persistence.jdbc..password" value="root"/>
<!-- Configurações específicas do Hibernate -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
独立模式下数据源和驱动程序的定义:
<datasource jndi-name="java:jboss/MySqlDS" pool-name="MySqlDS">
<connection-url>jdbc:mysql://localhost:3306/db_medical</connection-url>
<driver-class>com.mysql.cj.jdbc.Driver</driver-class>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<validate-on-match>true</validate-on-match>
<background-validation>false</background-validation>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
</datasource>
<driver name="mysql" module="com.mysql">
<driver-class>com.mysql.cj.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.cj.jdbc.MysqlXADataSource</xa-datasource-class>
</driver>
错误日志:
08:48:34,097 INFO [org.jboss.as.repository] (External Management Request Threads -- 1) WFLYDR0001: Content added at location C:\Users\Ilo Gabriel\eclipse-workspace\wildfly-27.0.1.Final\standalone\data\content\ac\a7e4b6ad429643a5813552677f49ab30f6fdb9\content
08:48:34,188 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 100) WFLYUT0022: Unregistered web context: '/itcmedbr' from server 'default-server'
08:48:34,370 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 218) WFLYJPA0011: Stopping Persistence Unit (phase 2 of 2) Service 'itcmedbr.war#itcmedbr_PU'
08:48:34,393 INFO [org.hibernate.orm.beans] (ServerService Thread Pool -- 218) HHH10005004: Stopping BeanContainer : org.hibernate.resource.beans.container.internal.CdiBeanContainerExtendedAccessImpl@5a4ec8bd
08:48:34,408 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 218) WFLYJPA0011: Stopping Persistence Unit (phase 1 of 2) Service 'itcmedbr.war#itcmedbr_PU'
08:48:35,232 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0028: Stopped deployment itcmedbr.war (runtime-name: itcmedbr.war) in 1116ms
08:48:35,254 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0027: Starting deployment of "itcmedbr.war" (runtime-name: "itcmedbr.war")
08:48:48,146 INFO [org.jboss.as.jpa] (MSC service thread 1-7) WFLYJPA0002: Read persistence.xml for itcmedbr_PU
08:48:48,840 INFO [org.jipijapa] (MSC service thread 1-6) JIPIORMV6020260: Second level cache enabled for itcmedbr.war#itcmedbr_PU
08:48:48,880 INFO [org.infinispan.CONTAINER] (ServerService Thread Pool -- 218) ISPN000556: Starting user marshaller 'org.wildfly.clustering.infinispan.marshalling.jboss.JBossMarshaller'
08:48:49,127 INFO [org.jboss.weld.deployer] (MSC service thread 1-6) WFLYWELD0003: Processing weld deployment itcmedbr.war
08:48:49,502 WARN [org.wildfly.extension.microprofile.opentracing] (MSC service thread 1-6) WFLYTRACEXT0012: No Jaeger endpoint or sender-binding configured. Installing a no-op sender
08:48:49,507 INFO [io.jaegertracing.internal.JaegerTracer] (MSC service thread 1-6) No shutdown hook registered: Please call close() manually on application shutdown.
08:48:49,509 INFO [org.wildfly.microprofile.opentracing.smallrye] (MSC service thread 1-6) WFLYTRAC0001: Tracer initialized: JaegerTracer(version=Java-1.6.0, serviceName=itcmedbr.war, reporter=RemoteReporter(sender=NoopSender(), closeEnqueueTimeout=1000), sampler=ConstSampler(decision=true, tags={sampler.type=const, sampler.param=true}), tags={hostname=DESKTOP-MOJECP9, jaeger.version=Java-1.6.0, ip=192.168.100.185}, zipkinSharedRpcSpan=false, expandExceptionLogs=false, useTraceId128Bit=false)
08:48:49,723 INFO [org.jipijapa] (MSC service thread 1-5) JIPIORMV6020260: Second level cache enabled for itcmedbr.war#itcmedbr_PU
08:48:49,949 ERROR [org.jboss.as.controller.management-operation] (External Management Request Threads -- 1) WFLYCTL0013: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.jboss.java:MySqlDS"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.persistenceunit.\"itcmedbr.war#itcmedbr_PU\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jboss.java:MySqlDS]",
"jboss.persistenceunit.\"itcmedbr.war#itcmedbr_PU\" is missing [jboss.naming.context.java.jboss.java:MySqlDS]"
]
}
08:48:49,951 ERROR [org.jboss.as.controller.management-operation] (External Management Request Threads -- 1) WFLYCTL0013: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.jboss.java:MySqlDS"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.persistenceunit.\"itcmedbr.war#itcmedbr_PU\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jboss.java:MySqlDS]",
"jboss.persistenceunit.\"itcmedbr.war#itcmedbr_PU\" is missing [jboss.naming.context.java.jboss.java:MySqlDS]"
]
}
08:48:50,598 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0028: Stopped deployment itcmedbr.war (runtime-name: itcmedbr.war) in 645ms
08:48:50,600 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0027: Starting deployment of "itcmedbr.war" (runtime-name: "itcmedbr.war")
08:48:50,600 ERROR [org.jboss.as.server] (External Management Request Threads -- 1) WFLYSRV0014: Replacement of deployment "itcmedbr.war" by deployment "itcmedbr.war" was rolled back with the following failure message:
{
"WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.jboss.java:MySqlDS"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.persistenceunit.\"itcmedbr.war#itcmedbr_PU\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jboss.java:MySqlDS]",
"jboss.persistenceunit.\"itcmedbr.war#itcmedbr_PU\" is missing [jboss.naming.context.java.jboss.java:MySqlDS]"
]
}
08:49:04,360 INFO [org.jboss.as.jpa] (MSC service thread 1-1) WFLYJPA0002: Read persistence.xml for itcmedbr_PU
08:49:05,174 INFO [org.jipijapa] (MSC service thread 1-6) JIPIORMV6020260: Second level cache enabled for itcmedbr.war#itcmedbr_PU
08:49:05,210 INFO [org.infinispan.CONTAINER] (ServerService Thread Pool -- 218) ISPN000556: Starting user marshaller 'org.wildfly.clustering.infinispan.marshalling.jboss.JBossMarshaller'
08:49:05,266 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 245) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'itcmedbr.war#itcmedbr_PU'
08:49:05,268 INFO [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 245) HHH000204: Processing PersistenceUnitInfo [name: itcmedbr_PU]
08:49:05,295 WARN [org.hibernate.orm.deprecation] (ServerService Thread Pool -- 245) HHH90000021: Encountered deprecated setting [javax.persistence.sharedCache.mode], use [jakarta.persistence.sharedCache.mode] instead
08:49:07,622 INFO [org.jboss.weld.deployer] (MSC service thread 1-8) WFLYWELD0003: Processing weld deployment itcmedbr.war
08:49:07,922 WARN [org.wildfly.extension.microprofile.opentracing] (MSC service thread 1-8) WFLYTRACEXT0012: No Jaeger endpoint or sender-binding configured. Installing a no-op sender
08:49:07,931 INFO [io.jaegertracing.internal.JaegerTracer] (MSC service thread 1-8) No shutdown hook registered: Please call close() manually on application shutdown.
08:49:07,932 INFO [org.wildfly.microprofile.opentracing.smallrye] (MSC service thread 1-8) WFLYTRAC0001: Tracer initialized: JaegerTracer(version=Java-1.6.0, serviceName=itcmedbr.war, reporter=RemoteReporter(sender=NoopSender(), closeEnqueueTimeout=1000), sampler=ConstSampler(decision=true, tags={sampler.type=const, sampler.param=true}), tags={hostname=DESKTOP-MOJECP9, jaeger.version=Java-1.6.0, ip=192.168.100.185}, zipkinSharedRpcSpan=false, expandExceptionLogs=false, useTraceId128Bit=false)
08:49:08,081 INFO [org.jipijapa] (MSC service thread 1-4) JIPIORMV6020260: Second level cache enabled for itcmedbr.war#itcmedbr_PU
08:49:08,251 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 245) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'itcmedbr.war#itcmedbr_PU'
08:49:08,266 INFO [SQL dialect] (ServerService Thread Pool -- 245) HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
08:49:08,278 INFO [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 245) Envers integration enabled? : true
08:49:10,084 INFO [jakarta.enterprise.resource.webcontainer.faces.config] (ServerService Thread Pool -- 286) Inicializando Mojarra 4.0.0.SP01 para o contexto '/itcmedbr'
08:49:11,832 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 286) WFLYUT0021: Registered web context: '/itcmedbr' for server 'default-server'
08:49:11,974 INFO [org.jboss.as.repository] (External Management Request Threads -- 1) WFLYDR0002: Content removed from location C:\Users\Ilo Gabriel\eclipse-workspace\wildfly-27.0.1.Final\standalone\data\content\ac\a7e4b6ad429643a5813552677f49ab30f6fdb9\content
我感谢任何帮助。 谢谢并致以诚挚的问候。
更改 persistence.xml 后:
来自:java:MySqlDS 到: java:jboss/MySqlDS
问题解决了。
我的 IDE Eclipse 让我犯了错误,当我以正确的方式写入时,Eclipse 会用红色强调单词 jboss,当我指向单词 Eclipse 时,会显示“单词‘jboss’拼写不正确”。现在我正在部署我的应用程序。 谢谢大家。