maven+jetty容器搭建

1 从svn地址下载项目应用到本地磁盘

   E:\CMS\icntv-cmsV2.0.1

 

2 maven服务设置:需要在User Settints中配置:C:\Users\shili\.m2\settings.xml

 

3利用myeclipse工具导入maven项目:

import->Exitsing Maven Projects

Root Directory  选择:

E:\CMS\icntv-cmsV2.0.1\yst-cms-webapp\pom.xml

 

3根据maven更新jar包:

maven4myeclipse

 

4 下载jetty6.x版本,因为项目应用用的是mysql数据库,且数据源的配置是用的maven之前的工具包,只有6.X之前的版本才能支持

例如class类:org.mortbay.jetty.plus.naming.Resource

 

5 数据库配置文件放在:E:\CMS\icntv-cmsV2.0.1\yst-cms-webapp\src\main\webapp\WEB-INF\jetty-env.xml 此文件在发布到jetty容器后会自动加载到服务当中,不需要另外配置数据库连接,配置文件内容如下:

<?xml version="1.0" encoding="utf-8"?> 
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" 
"http://jetty.mortbay.org/configure.dtd"> 
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
    <New id="cmsDataSource" class="org.mortbay.jetty.plus.naming.Resource">
     <Arg>jdbc/CMS</Arg>
     <Arg>
         <New class="org.apache.commons.dbcp.BasicDataSource">
            <Set name="driverClassName">com.mysql.jdbc.Driver</Set>
            <Set name="url">jdbc:mysql://192.168.75.204:3306/cms?useUnicode=true&amp;zeroDateTimeBehavior=convertToNull&amp;characterEncoding=UTF-8&amp;characterSetResults=UTF-8&amp;autoReconnect=true</Set>
            <Set name="username">root</Set>
            <Set name="password">root</Set>
         </New>
     </Arg>
    </New>
   
    <New id="cisdataSource" class="org.mortbay.jetty.plus.naming.Resource">
  <Arg>jdbc/CIS</Arg>
  <Arg>
   <New class="org.apache.commons.dbcp.BasicDataSource">
    <Set name="driverClassName">com.mysql.jdbc.Driver</Set>
    <Set name="url">jdbc:mysql://192.168.75.204:3306/cis?useUnicode=true&amp;zeroDateTimeBehavior=convertToNull&amp;characterEncoding=UTF-8&amp;characterSetResults=UTF-8&amp;autoReconnect=true
    </Set>
             <Set name="username">root</Set>
             <Set name="password">root</Set>
   </New>
  </Arg>
 </New>
 
  <New id="drmsDataSource" class="org.mortbay.jetty.plus.naming.Resource">
  <Arg>jdbc/DRMS</Arg>
  <Arg>
   <New class="org.apache.commons.dbcp.BasicDataSource">
    <Set name="driverClassName">com.mysql.jdbc.Driver</Set>
    <Set name="url">jdbc:mysql://192.168.75.204:3306/drms?useUnicode=true&amp;zeroDateTimeBehavior=convertToNull&amp;characterEncoding=UTF-8&amp;characterSetResults=UTF-8&amp;autoReconnect=true
    </Set>
             <Set name="username">root</Set>
             <Set name="password">root</Set>
   </New>
  </Arg>
 </New>
 <New id="pubDataSource" class="org.mortbay.jetty.plus.naming.Resource">
  <Arg>jdbc/PUB</Arg>
  <Arg>
   <New class="org.apache.commons.dbcp.BasicDataSource">
    <Set name="driverClassName">com.mysql.jdbc.Driver</Set>
    <Set name="url">jdbc:mysql://192.168.75.204:3306/pub?useUnicode=true&amp;zeroDateTimeBehavior=convertToNull&amp;characterEncoding=UTF-8&amp;characterSetResults=UTF-8&amp;autoReconnect=true
    </Set>
             <Set name="username">root</Set>
             <Set name="password">root</Set>
   </New>
  </Arg>
 </New>
    <New id="epgDataSource" class="org.mortbay.jetty.plus.naming.Resource">
     <Arg>jdbc/EPG</Arg>
     <Arg>
         <New class="org.apache.commons.dbcp.BasicDataSource">
            <Set name="driverClassName">com.mysql.jdbc.Driver</Set>
            <Set name="url">jdbc:mysql://192.168.75.204:3306/epg?useUnicode=true&amp;zeroDateTimeBehavior=convertToNull&amp;characterEncoding=UTF-8&amp;characterSetResults=UTF-8&amp;autoReconnect=true</Set>
            <Set name="username">root</Set>
            <Set name="password">root</Set>
         </New>
     </Arg>
    </New>
    <New id="cdnDataSource" class="org.mortbay.jetty.plus.naming.Resource">
     <Arg>jdbc/CDN</Arg>
     <Arg>
         <New class="org.apache.commons.dbcp.BasicDataSource">
            <Set name="driverClassName">com.mysql.jdbc.Driver</Set>
            <Set name="url">jdbc:mysql://192.168.75.204:3306/cdn?useUnicode=true&amp;zeroDateTimeBehavior=convertToNull&amp;characterEncoding=UTF-8&amp;characterSetResults=UTF-8&amp;autoReconnect=true</Set>
            <Set name="username">root</Set>
            <Set name="password">root</Set>
         </New>
     </Arg>
    </New>
 <New id="prepDataSource" class="org.mortbay.jetty.plus.naming.Resource">
     <Arg>jdbc/PREP</Arg>
     <Arg>
         <New class="org.apache.commons.dbcp.BasicDataSource">
            <Set name="driverClassName">com.mysql.jdbc.Driver</Set>
            <Set name="url">jdbc:mysql://192.168.75.204:3306/prep?useUnicode=true&amp;zeroDateTimeBehavior=convertToNull&amp;characterEncoding=UTF-8&amp;characterSetResults=UTF-8&amp;autoReconnect=true</Set>
            <Set name="username">root</Set>
            <Set name="password">root</Set>
         </New>
     </Arg>
    </New>
    <New id="edataDataSource" class="org.mortbay.jetty.plus.naming.Resource">
     <Arg>jdbc/EDATA</Arg>
     <Arg>
         <New class="org.apache.commons.dbcp.BasicDataSource">
            <Set name="driverClassName">com.mysql.jdbc.Driver</Set>
            <Set name="url">jdbc:mysql://192.168.75.204:3306/edata?useUnicode=true&amp;zeroDateTimeBehavior=convertToNull&amp;characterEncoding=UTF-8&amp;characterSetResults=UTF-8&amp;autoReconnect=true</Set>
            <Set name="username">root</Set>
            <Set name="password">root</Set>
         </New>
     </Arg>
    </New>
   
</Configure>

6 搭建项目时遇到的问题

1)找不到jar包

2)更改web context-root 路径指向,由于目录下面有两个web.xml文件,发布服务不正确,需要更改:context-root

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值