[英]Issue configuring Tomcat 7 JDNI datasource in Context file
這是我得到的例外:
Error creating bean with name 'jndiDataSource' defined in class path resource [spring/database.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [connection_pool] is not bound in this Context. Unable to find [connection_pool]
這是我的數據源bean:
<bean id="jndiDataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="connection_pool" />
</bean>
這是我放入tomcat7/conf/Catalina/localhost
上下文文件MyApp##1.0.2.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="path\to\war\my-app-1.0.2.war"
antiResourceLocking="false" privileged="true" >
<Resource name="connection_pool"
url="jdbc:mysql://localhost:3306/db_name"
driverClassName="com.mysql.jdbc.Driver"
username="username" password="password"
auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000" />
</Context>
有誰知道為什么它不起作用?
請嘗試此操作,它應提供正確的配置:
<jee:jndi-lookup id="myDataSource" jndi-name="java:connection_pool" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.