0 0

Maven 多模块中 jetty插件热部署设置25

现在我的Maven如下
--all-build
-----core
-----log
-----webapp

all-build 是总的模块。pom类型是pom
core 是核心代码 。pom类型是jar
log 依赖core 。pom类型是jar
webapp 依赖core 和 log ,pom类型是war

要求:
1.jetty可以对webapp进行run,要怎么设置,现在如果我在webapp中增加依赖,他会去我的Nexus私服去download,提示没有该jar,如果只是添加工程依赖,则报类找不到
2.当对core和log任意的module进行修改,都不用重启jetty,实现热部署

分全给了,希望大神们解答详细点啊,本人不才。。。

1个答案 按时间排序 按投票排序

0 0

采纳的答案

simple-parent项目中有一个pom.xml这个xml引用五个子模块

simple-model
simple-weather
simple-persist
simple-webapp
simple-command

simple-model,simple-weather,simple-persist,simple-webapp,simple-command

顶级的pom.xml simple-parent.pom

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.sonartype.mavenbook.ch07</groupId>
  <artifactId>simple-parent</artifactId>
  <packaging>pom</packaging>
  <version>1.0</version>
  <name>Parent Project</name>
  <modules>
   <module>simple-command</module>
 <module>simple-model</module>
 <module>simple-weather</module>
 <module>simple-persist</module>
 <module>simple-webapp</module>
  </modules>
  <build>
    <pluginManagement>
 <plugins>
  <plugin>
    <groupId>com.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <version>6.1.7</version>
   <configuration>
    <source>1.5</source>
    <target>1.5</target>
   </configuration>  
  </plugin>
     </plugins>
    </pluginManagement>
  </build>
    <dependencies>
 <dependency>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>3.8.1</version>
     <scope>test</scope>
 </dependency>
     </dependencies>
</project>


simple-model 的pom.xml

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
 <groupId>com.sonartype.mavenbook.ch07</groupId>
 <artifactId>simple-parent</artifactId>
 <version>1.0</version>
   </parent>

   <artifactId>simple-model</artifactId>

  <packaging>jar</packaging>

<name>simple object model</name>

    <dependencies>
 <dependency>
     <groupId>org.hibernate</groupId>
     <artifactId>hibernate-annotations</artifactId>
     <version>3.3.0.ga</version>
     <scope>test</scope>
 </dependency>
 <dependency>
     <groupId>org.hibernate</groupId>
     <artifactId>hibernate-commons-annotations</artifactId>
     <version>3.3.0.ga</version>
     <scope>test</scope>
 </dependency>
     </dependencies>
</project>



simple-weather 的pom.xml

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
 <groupId>com.sonartype.mavenbook.ch07</groupId>
 <artifactId>simple-parent</artifactId>
 <version>1.0</version>
   </parent>

  <artifactId>simple-weather</artifactId>
  <packaging>jar</packaging>

<name>simple-weather</name>
    <dependencies>
 <dependency>
     <groupId>log4j</groupId>
     <artifactId>log4j</artifactId>
     <version>1.2.14</version>
 </dependency>
 <dependency>
     <groupId>dom4j</groupId>
     <artifactId>dom4j</artifactId>
     <version>1.6.1</version>
 </dependency>
     </dependencies>
</project>


simple-persist pom

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
 <groupId>com.sonartype.mavenbook.ch07</groupId>
 <artifactId>simple-parent</artifactId>
 <version>1.0</version>
   </parent>

  <artifactId>simple-weather</artifactId>
  <packaging>jar</packaging>

<name>simple-persist</name>
    <dependencies>
 <dependency>
     <groupId>com.sonartype.mavenbook.ch07</groupId>
     <artifactId>simple-model</artifactId>
     <version>1.0</version>
 </dependency>
 <dependency>
     <groupId>org.hibernate</groupId>
     <artifactId>hibernate</artifactId>
     <version>3.2.5.ga</version>
     <exclusions>
     <exclusion>
    <groupId>javax.transaction</groupId>
    <artifactId>jta</artifactId>
     </exclusion>
     </exclusions>
 </dependency>
 <dependency>
     <groupId>org.hibernate</groupId>
     <artifactId>hibernate-annotations</artifactId>
     <version>3.3.0.ga</version>
     <scope>test</scope>
 </dependency>
 <dependency>
     <groupId>org.hibernate</groupId>
     <artifactId>hibernate-commons-annotations</artifactId>
     <version>3.3.0.ga</version>
     <scope>test</scope>
 </dependency>
 <dependency>
     <groupId>org.apache.geronimo.spece</groupId>
     <artifactId>geronimo-jta_1.1_spec</artifactId>
     <version>1.1</version>
 </dependency>
 <dependency>
     <groupId>org.springframework</groupId>
     <artifactId>spring</artifactId>
     <version>2.0.7</version>
 </dependency>
     </dependencies>
</project>


simple-webapp pom
<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
 <groupId>com.sonartype.mavenbook.ch07</groupId>
 <artifactId>simple-parent</artifactId>
 <version>1.0</version>
   </parent>

  <artifactId>simple-webapp</artifactId>
  <packaging>war</packaging>

<name>simple-webapp</name>
    <dependencies>
     <dependency>
     <groupId>org.apache.geronimo.spece</groupId>
     <artifactId>geronimo-jta_1.1_spec</artifactId>
     <version>1.1</version>
 </dependency>
 <dependency>
     <groupId>com.sonartype.mavenbook.ch07</groupId>
     <artifactId>simple-weather</artifactId>
     <version>1.0</version>
 </dependency>
 <dependency>
     <groupId>com.sonartype.mavenbook.ch07</groupId>
     <artifactId>simple-persist</artifactId>
     <version>1.0</version>
 </dependency>
 <dependency>
     <groupId>org.hibernate</groupId>
     <artifactId>hibernate</artifactId>
     <version>3.2.5.ga</version>
     <exclusions>
     <exclusion>
    <groupId>javax.transaction</groupId>
    <artifactId>jta</artifactId>
     </exclusion>
     </exclusions>
 </dependency>
     </dependencies>
     <build>
 <finalName>simple-webapp</finalName>
 <plugins>
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.7</version>
                <configuration>
                    <scanIntervalSeconds>5</scanIntervalSeconds>
                    <connectors>
                        <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                            <port>8080</port>
                            <maxIdleTime>60000</maxIdleTime>
                        </connector>
                    </connectors>
                </configuration>
  <dependency>
     <groupId>hsqldb</groupId>
     <artifactId>hsqldb</artifactId>
     <version>1.8.0.7</version>
  </dependency>
            </plugin>
      <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>hibernate3-maven-plugin</artifactId>
                <version>2.0</version>
  <configuration>
                    <components>
   <component>
    <name>hbm2ddl<name>
    <implementation>annotationconfiguration</implementation>
   <component>
      </components>
                </configuration>
  <dependency>
     <groupId>hsqldb</groupId>
     <artifactId>hsqldb</artifactId>
     <version>1.8.0.7</version>
  </dependency>
            </plugin>
 </plugins>
 </build>
</project>


jetty 插件 配置 需要配置在 打成war包的项目中
<project>
<build>
<plugins>
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.7</version>
                <configuration>
                    <scanIntervalSeconds>5</scanIntervalSeconds>
                    <connectors>
                        <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                            <port>8080</port>
                            <maxIdleTime>60000</maxIdleTime>
                        </connector>
                    </connectors>
                </configuration>  
            </plugin>
</plugins>
</build>
</project>

2012年12月19日 11:08

相关推荐

    maven多模块项目+jetty热部署实例源码

    eclipse + maven多模块项目框架 + jetty热部署的实例源码 让你掌握maven中那些令人迷惑的一堆配置,基于此框架快速搭建maven多模块项目完美环境。

    maven项目下用 jetty 启动热部署

    maven的项目用jetty 服务器启动项目时配置此段配置,就可以实现热部署(意思就是eclipse改了代码可以不用重启服务器)

    Intellij IDEA下建立maven管理的web项目,配置jetty热部署

    在 Maven 项目中,我们可以使用 Jetty 插件来实现热部署。 知识点 5:Maven 的依赖管理 Maven 项目可以依赖其他项目或 jar 包,通过在 POM 文件中配置依赖关系,Maven 会自动下载和管理依赖项。在本示例中,我们...

    eclipse + maven多模块项目 + SpringMVC + jetty热部署实现验证码图片实例源码

    应网友要求,重新整理原《eclipse + maven多模块项目框架 + jetty热部署的实例源码》,增加了各配置的详细注释。 并且基于Spring MVC提供了一个完整功能:实现了生成验证码图片,以及验证输入是否匹配的两个接口,...

    Eclipse+maven+jetty环境配置

    详解介绍Eclipse+maven+jetty环境配置

    Jetty中文手册

    热部署 Context提供者 如何部署web应用 webApp提供者 如何部署第三方产品 部署展开形式的web应用 使用Jetty进行开发 如何使用Jetty进行开发 如何编写Jetty中的Handlers 使用构建工具 如何在Maven中使用Jetty 如何在...

    maven常用知识整理

    maven常用知识整理:项目依赖 多模块 WAR依赖 打包 热部署 maven-tomcat-plugin maven-jetty-plugin

    IntelliJ+Maven+Jetty+Jrebel实现web项目java代码更改后热部署

    NULL 博文链接:https://wang-jia-sina-com.iteye.com/blog/1730307

    tomcat-maven-plugin

    maven-tomcat-plugin让maven与tomcat配合得很好。它可以把应用部署到Tomcat服务器,也可以把tomcat作为内嵌服务器启动,就像jetty一样。 使用JPDA启动tomcat的远程调试功能。...而且具有tomcat的热部署功能。

    jetty-distribution-9.4.0.v20161208.zip

    * contexts 热部署目录 * etc jetty配置文件目录 * examples jetty示例 * extras jetty可选扩展 * lib 包含jetty所需的jar文件 * LICENSES 就是LICENSES * modules 子模块 * patches 补丁patches * pom.xml is jetty...

    jfinal资源包包含源码

    即可开始开发,同时它也是支持热部署的必要包。特别注意在使用tomcat开发或部署时需要去掉 jetty-server-8.1.8.jar 包,以免引起冲突 5:jfinal-2.2-lib 目录下所有 jar 包 为开发者准备的常用且可能用到的 jar ...

    SpringBoot高频面试题含答案

    可以通过打包用命令、放到容器中运行、使用 Maven/Gradle 插件运行、直接执行 main 方法运行等方式来运行 Spring Boot。 10. Spring Boot 是否需要独立的容器运行 Spring Boot 不需要独立的容器运行,可以内置 ...

    springboot参考指南

    使用Spring Boot Maven插件 ii. 13.2. Gradle iii. 13.3. Ant iv. 13.4. Starter POMs ii. 14. 组织你的代码 i. 14.1. 使用"default"包 ii. 14.2. 定位main应用类 iii. 15. 配置类 目錄 Spring Boot参考指南 2 i. ...

    SpringBoot面试题 44道.pdf

    14. SpringBoot 实现热部署有哪几种方式? 1. Spring Loaded 2. Spring-boot-devtools 15. SpringBoot 事务的使用 使用 @EnableTransactionManagement 注解开启事务,然后在 Service 方法上添加 @Transactional ...

    WebSocketClient

    包括嵌入式(默认情况下热重载)。 构建状态: 安装 克隆这个 repo mvn clean install 跑步 mvn jetty:run 控制台日志应如下所示。 应用说明 这是一个普通的 JEE7 Web 应用程序。 在启动时,它使用 ...

    Java 实时社区论坛.zip

    安装需求:Maven3 、MySQL5 、Jetty9 /Tomcat9 (理论上只要实现了 JSR356 规范的 Servlet 容器都可以)下载源码解压后修改 src/main/resources/local.properties 中的数据库配置,并创建数据库可能需要修改 latke....

Global site tag (gtag.js) - Google Analytics