独立应用程序中的JNDI对象创建 [英] JNDI object creation in standalone application

查看:157
本文介绍了独立应用程序中的JNDI对象创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以创建JNDI llookup并且它在独立应用程序中的引用意味着没有任何应用程序服务器。

Is is possible to create JNDI llookup and it's reference in standalone application means without any application server.

java:comp/env/jdbc

问候,

Chaitu

推荐答案

你可以使用类 org.springframework.mock.jndi.SimpleNamingContextBuilder 依赖关系或文件 spring-mock-1.0.2.jar 。例如:

You can use the class org.springframework.mock.jndi.SimpleNamingContextBuilder of Spring, either the dependency or the file spring-mock-1.0.2.jar. e.g.:


  • 设置:

SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
builder.bind("jdbc/Oracle", ods);
builder.activate();



  • 使用:

DataSource ds = InitialContext.doLookup("jdbc/Oracle");


这篇关于独立应用程序中的JNDI对象创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆