其他分享
首页 > 其他分享> > 如何在Spring中使用WebLogic 12.2.1提供的JNDI DataSource?

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

作者:互联网

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

我选择了通用数据源选项

名称: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文件都是必需的.请帮忙.

解决方法:

有时,当您忘记将定义的数据源定位到特定服务器时会发生这种情况.您可以在Weblogic的管理服务器中找到它:

enter image description here

然后在Targets选项卡中:

enter image description here

你应该选择目标.

如果这不是问题,您可以尝试在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引用.

希望这会有所帮助.

标签:java,spring,jndi,weblogic12c
来源: https://codeday.me/bug/20190523/1156601.html