如何在Spring中使用WebLogic 12.2.1提供的JNDI DataSource?

问题描述 投票:5回答:1

我使用以下值创建了JNDI连接:

我选择了Generic Data Source选项

名称:jdbc / sampleDataSource

JNDI名称:jdbc / sampleDataSource

Spring配置文件:

<jee:jndi-lookup id="dataSource" jndi-name="jdbc/sampleDataSource" />

我低于错误。

Error An error occurred during activation of changes, please see the log for details.
Error javax.naming.NameNotFoundException: While trying to lookup 'jdbc.sampleDataSource' didn't find subcontext 'jdbc'. Resolved ''; remaining name 'jdbc/sampleDataSource'
Error While trying to lookup 'jdbc.sampleDataSource' didn't find subcontext 'jdbc'. Resolved ''; remaining name 'jdbc/sampleDataSource' 

我无法解决它。我如何在Spring 4中配置。任何添加jar文件都是必需的。请帮忙。

java spring jndi weblogic12c
1个回答
5
投票

有时这会发生在您忘记将Target定义为特定服务器的datasource时。你可以在Weblogic的管理服务器中找到它:

enter image description here

然后在Targets标签中:

enter image description here

你应该选择目标。

如果这不是问题,你可以尝试在datasource获得你的applicationContext.xml

<bean id="dataSource" name="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jdbc/mcdsDS"/>
    <property name="resourceRef" value="true"/>
</bean>

并在需要datasource的任何地方使用dataSource参考。

希望这会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.