我正在尝试使用tomcat mysql来开发Web应用程序,这是我的配置:persistence.xml中persistence-unit name=EntityMappings transaction-type=RESOURCE_LOCALproviderorg.hibernate.jpa.HibernatePersistencePr...

我正在尝试使用tomcat mysql来开发Web应用程序,这是我的配置:
persistence.xml中
<persistence-unit name="EntityMappings" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<non-jta-data-source>
java:comp/env/jdbc/EntityMappings
</non-jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<validation-mode>NONE</validation-mode>
<properties>
<property name="javax.persistence.schema-generation.database.action"
value="none" />
</properties>
</persistence-unit>
web.xml中
<resource-ref>
<description>MySQL Datasource example</description>
<res-ref-name>jdbc/EntityMappings</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
context.xml(在tomcat / config下)
<Resource name="jdbc/EntityMappings" auth="Container" type="javax.sql.DataSource"
maxActive="50" maxIdle="30" maxWait="10000"
username="XXX" password="XXX"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/EntityMappings"/>
我的架构是EntityMappings.
运行后我遇到了一些错误:
Name [java:comp/env/jdbc/EntityMappings] is not bound in this Context. Unable to find [java:comp].
Unable to lookup JNDI name [java:comp/env/jdbc/EntityMappings]
javax.persistence.PersistenceException: Unable to build entity manager factory
我已将mysql驱动程序放在我的tomcat / lib下(mysql-connector-java-5.1.30-bin.jar)
解决方法:
尝试从persistence.xml中删除java:comp / env前缀:
<non-jta-data-source>
jdbc/EntityMappings
</non-jta-data-source>
织梦狗教程
本文标题为:Tomcat Mysql – 无法找到java:comp


基础教程推荐
猜你喜欢
- 深入了解Java方法的重载与重写 2023-03-15
- Springboot详解底层启动过程 2023-02-27
- SpringBoot中对应2.0.x版本的Redis配置详解 2023-01-29
- SpringBoot超详细讲解@Enable*注解和@Import 2023-03-06
- RocketMQ Namesrv架构工作原理详解 2023-04-06
- Redis实现商品秒杀功能页面流程 2023-05-18
- SpringBoot+ShardingSphereJDBC实现读写分离详情 2023-04-06
- SpringBoot中处理的转发与重定向方式 2023-07-01
- Java类型转换valueOf与parseInt区别探讨解析 2023-06-01
- Spring Boot 中starter的原理详析 2022-12-02