0

これは私が得る例外です:

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>

MyApp##1.0.2.xmlこれは、ドロップしたコンテキスト ファイルですtomcat7/conf/Catalina/localhost

<?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>

なぜこれが機能しないのか、誰にもアイデアがありますか?

4

1 に答える 1

0

代わりにこれを試してください。正しい構成が提供されるはずです。

<jee:jndi-lookup id="myDataSource" jndi-name="java:connection_pool" />
于 2012-11-30T22:31:13.890 に答える