设为首页 收藏本站
查看: 830|回复: 0

[经验分享] Maven 多模块项目在eclipse下面热部署(Tomcat7、Jetty)

[复制链接]

尚未签到

发表于 2017-2-27 12:32:35 | 显示全部楼层 |阅读模式
  多模块项目的结构,“erpt-test” 是主项目,“erpt-parent”是所有子模块的parent。
DSC0000.jpg



  • Tomcat7 配置: 在“erpt-test”的POM里配置


    1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    2   <modelVersion>4.0.0</modelVersion>
    3   <groupId>com.sgm.erpt</groupId>
    4   <artifactId>erpt-test</artifactId>
    5   <version>0.0.1-SNAPSHOT</version>
    6   <packaging>pom</packaging>
    7   <modules>
    8       <module>erpt-parent</module>
    9       <module>erpt-parent-service</module>
    10       <module>erpt-data</module>
    11       <module>erpt-parent-dao</module>
    12       <module>erpt-project1-dao</module>
    13       <module>erpt-project1-service</module>
    14       <module>erpt-parent-web</module>
    15       <module>erpt-parent-entity</module>
    16       <module>erpt-project1-entity</module>
    17       <module>erpt-analyze</module>
    18       <module>erpt-project1-web</module>
    19       <module>erpt-web</module>
    20   </modules>
    21      
    22     <build>
    23         <plugins>
    24             <plugin>
    25                 <groupId>org.apache.tomcat.maven</groupId>
    26                 <artifactId>tomcat7-maven-plugin</artifactId>
    27                 <version>2.0-beta-1</version>
    28                 <configuration>
    29                     <port>9080</port>
    30                     <path>/</path>
    31                     <contextFile>D:/workspace_maven_test/erpt-test/erpt-web/src/main/resources/tomcatconf/context.xml</contextFile>
    32                     <contextReloadable>true</contextReloadable>
    33                     <useTestClasspath>false</useTestClasspath>
    34                 </configuration>
    35                 <dependencies>
    36                     <dependency>
    37                       <groupId>com.oracle</groupId>
    38                       <artifactId>ojdbc14</artifactId>
    39                       <version>xe</version>
    40                     </dependency>
    41                 </dependencies>
    42             </plugin>
    43         </plugins>
    44     </build>
    45 </project>
      其中contextFile主要配置的是JNDI数据源的



    1 <?xml version="1.0" encoding="UTF-8"?>
    2 <!--
    3   Licensed to the Apache Software Foundation (ASF) under one or more
    4   contributor license agreements.  See the NOTICE file distributed with
    5   this work for additional information regarding copyright ownership.
    6   The ASF licenses this file to You under the Apache License, Version 2.0
    7   (the "License"); you may not use this file except in compliance with
    8   the License.  You may obtain a copy of the License at
    9
    10       http://www.apache.org/licenses/LICENSE-2.0
    11
    12   Unless required by applicable law or agreed to in writing, software
    13   distributed under the License is distributed on an "AS IS" BASIS,
    14   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    15   See the License for the specific language governing permissions and
    16   limitations under the License.
    17 --><!-- The contents of this file will be loaded for each web application -->
    18
    19 <Context reloadable="false">
    20
    21     <!-- Default set of monitored resources -->
    22     <WatchedResource>WEB-INF/web.xml</WatchedResource>
    23     
    24     <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    25     <!--
    26     <Manager pathname="" />
    27     -->
    28
    29     <!-- Uncomment this to enable Comet connection tacking (provides events
    30          on session expiration as well as webapp lifecycle) -->
    31     <!--
    32     <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
    33     -->
    34
    35 <Resource
    36 name="jdbc/UM"
    37 type="javax.sql.DataSource"
    38 username="OWAVT"
    39 password="password"
    40 driverClassName="oracle.jdbc.driver.OracleDriver"
    41 url="jdbc:oracle:thin:@127.0.0.1:1521:XE" />
    42
    43 </Context>
      配置插件后会在项目的War项目的Target生成一个tomcat的文件夹,里面有个tomcat-users.xml文件



    1 <?xml version='1.0' encoding='utf-8'?>
    2 <!--
    3   Licensed to the Apache Software Foundation (ASF) under one or more
    4   contributor license agreements.  See the NOTICE file distributed with
    5   this work for additional information regarding copyright ownership.
    6   The ASF licenses this file to You under the Apache License, Version 2.0
    7   (the "License"); you may not use this file except in compliance with
    8   the License.  You may obtain a copy of the License at
    9
    10       http://www.apache.org/licenses/LICENSE-2.0
    11
    12   Unless required by applicable law or agreed to in writing, software
    13   distributed under the License is distributed on an "AS IS" BASIS,
    14   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    15   See the License for the specific language governing permissions and
    16   limitations under the License.
    17 -->
    18 <tomcat-users>
    19
    20   <role rolename="tomcat"/>
    21   <role rolename="UMRole"/>
    22   <user username="tomcat" password="tomcat" roles="tomcat"/>
    23   <user username="both" password="tomcat" roles="tomcat,role1"/>
    24   <user username="test01" password="password" roles="UMRole"/>
    25
    26 </tomcat-users>
      最后在M2E里配置
    DSC0001.jpg


  •   run-jetty-run插件, run-jetty-run是一个用jetty运行/调试Web项目的Eclipse插件,通过M2E插件结合Maven使用简直就是Web项目调试神器。如果用tomcat什么的,想要在Eclipse里面直接调试使用Maven管理的多模块项目简直是一件折磨死人的事情,用RJR什么都不用配置,直接项目右键-->DEBUG AS-->Run jetty就行了,
    run-jetty-run update site: http://run-jetty-run.googlecode.com/svn/trunk/updatesite


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-347996-1-1.html 上篇帖子: 1.3.2 Jetty 的基本配置(2) 下篇帖子: ubuntu手动安装jdk并配置jetty
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表