eclipse内嵌jetty(run-jetty-run插件) 配置jndi数据源

运行环境 java 6,eclipse juno,ssh(spring,hibernate,springmvc )

1、离线安装

   下载地址:http://pan.baidu.com/s/1qX67wOc,下载后,解压,把features和plugins拷贝到eclipse安装目录的plugins下,重启eclipse。

2、在线安装(我用的这种)

   help--> install new software... -->

 地址:http://run-jetty-run.googlecode.com/svn/trunk/updatesite

(我的ping不到,我用的是这个地址  http://eclipse-jetty.github.io/update/  )

安装完成,重启eclipse。

 

开始配置.      

进入Run---> Debug Configurations... ---> 

新建一个Jetty Webapp (如下图)

然后在Options页签勾选Enable JNDI Support。

最后在WEB-INF 目录下新建jetty-env.xml

<?xml version="1.0" encoding="UTF-8" ?>  
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">  
<Configure class="org.eclipse.jetty.webapp.WebAppContext">  
    <!-- 应用数据源 -->  
    <New id="test" class="org.eclipse.jetty.plus.jndi.Resource">
        <Arg>jdbc/test-local</Arg>    <!--这个要和数据源里面的对应-->
        <Arg>  
            <New class="org.apache.commons.dbcp.BasicDataSource">  
                <Set name="driverClassName">oracle.jdbc.driver.OracleDriver</Set>  
                <Set name="url">jdbc:oracle:thin:@ ip:1521:orcl</Set>  
                <Set name="username">username</Set>  
                <Set name="password">password</Set>  
                <Set name="maxActive">500</Set>  
                <Set name="maxIdle">30</Set>  
                <Set name="maxWait">10000</Set>  
            </New>  
        </Arg>  
    </New>  
</Configure>

数据源我是这么配置的

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

 

最后以jetty 运行。

启动成功!

 

posted on 2016-01-28 14:35 CollinTsui 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/collin/p/jetty.html