gpt4 book ai didi

java - Jndi Spring 问题

转载 作者:行者123 更新时间:2023-12-02 07:47:43 25 4
gpt4 key购买 nike

我正在寻找使用 Spring 和 JNDI 但我在这里找不到问题:

我的Server.xml:

 <Resource name="jdbc/MimsDS"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
username="xxx" password="xxx"
url="jdbc:oracle:thin:@192.168.1.3:1526:mimsdb10"
maxActive="20" maxIdle="10" maxWait="-1"
validationQuery="select sysdate from dual"
/>

我的应用程序上下文:

<bean id="dataSource" class="org.springframework.jndi.JndiTemplate">
<property name="jndiName" value="java:comp/env/jdbc/MimsDS" />
<property name="resourceRef" value="true" />
</bean>

<bean id="simpleJdbcTemplate" class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
<property name="dataSource" ref="dataSource"/>
</bean>

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>

我收到此错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'calendarDaoImpl' defined in file [/usr/local/apache-tomcat-7.0/webapps/op-calendar/WEB-INF/classes/be/mims/opcalendar/services/CalendarDaoImpl.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: 'dataSource' or 'jdbcTemplate' is required

最佳答案

您应该使用JndiObjectFactoryBean,而不是JndiTemplate

关于java - Jndi Spring 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10600030/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com