用maven 部署项目到jetty容器

需要引入的插件:

<plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.26</version>
                <configuration>
                    <!--默认为0,表示禁用热部署检查。任何一个大于0的数字都将表示启用。 -->
                    <scanIntervalSeconds>10</scanIntervalSeconds>
           <webAppSourceDirectory>${basedir}/m2_webapp01/src/main/webapp</webAppSourceDirectory>

             <classesDirectory>${basedir}/m2_webapp01/target/classes</classesDirectory>
                    <webAppConfig>
                        <!--jetty插件启动后的访问路径: http://localhost:8080/testdemo-->
                        <contextPath>/testdemo</contextPath>
                        <tempDirectory>${project.build.directory}/work</tempDirectory>
                    </webAppConfig>
                </configuration>
            </plugin>

或者:

<plugin>
				<groupId>org.eclipse.jetty</groupId>
				<artifactId>jetty-maven-plugin</artifactId>
				<version>9.3.0.v20150612</version>
				<configuration>
					<httpConnector>
						<port>8081</port>
						<idleTimeout>60000</idleTimeout>
					</httpConnector>
					<scanIntervalSeconds>3</scanIntervalSeconds>
					<webApp>
						<contextPath>/</contextPath>
					</webApp>
					<jvmArgs>
						-Xms1024m
						-Xmx1024m
						-XX:MaxNewSize=512m
						-XX:PermSize=256m
						-XX:MaxPermSize=512m
						-XX:+UseConcMarkSweepGC
						-XX:+CMSPermGenSweepingEnabled
						-XX:+CMSClassUnloadingEnabled
					</jvmArgs>
				</configuration>
			</plugin>

或者:

<plugin>
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>maven-jetty-plugin</artifactId>
                    <version>6.1.25</version>
                    <configuration>
                        <scanIntervalSeconds>0</scanIntervalSeconds>
                        <contextPath>/</contextPath>
                        <connectors>
                            <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                                <port>${jetty.port}</port>
                                <maxIdleTime>60000</maxIdleTime>
                            </connector>
                        </connectors>
                        <stopKey>stopkey</stopKey>
                        <stopPort>${jetty.stopPort}</stopPort>
                    </configuration>
                </plugin>

 

运行:mvn  jetty:run

如果报错

在settings.xml 加这么一句后, 解决. 
 

<pluginGroups> 
    <pluginGroup>org.mortbay.jetty</pluginGroup> 
  </pluginGroups> 

拓展:

在springboot的应用的根目录下运行mvn spring-boot:run

用jdk

1 mvn install  2 java -jar xxxx.jar

带参数:

Maven启动指定Profile通过-P,如mvn spring-boot:run -Ptest,但这是Maven的Profile。

如果要指定spring-boot的spring.profiles.active,则必须使用mvn spring-boot:run -Drun.profiles=test

如果使用命令行直接运行jar文件,则使用java -jar -Dspring.profiles.active=test demo-0.0.1-SNAPSHOT.jar

如果使用开发工具,运行Application.java文件启动,则增加参数--spring.profiles.active=test

热部署1:

springloaded

Pom.xml中直接在spring-boot插件中添加依赖即可:

<plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <dependencies>
            <!-- spring热部署 -->
            <dependency>
              <groupId>org.springframework</groupId>
              <artifactId>springloaded</artifactId>
              <version>1.2.6.RELEASE</version>
            </dependency>
          </dependencies>
          <configuration>
            <mainClass>cn.springboot.Mainspringboot</mainClass>
          </configuration>
        </plugin>

热部署2:

-javaagent:F:/jrebel-3.0-M1/jrebel.jar   
-Drebel.dirs=F:\MyEclipse7.0M1\eclipse\workspace\qhtjProject_new\WebRoot\WEB-INF\classes  
-Drebel.disable_update: 设为true,就不会联网检查更新

运行:

$ mvn clean spring-boot:run

  参考:https://blog.csdn.net/my__Sun_/article/details/72866329

spirng boot 自动化部署:

参考:http://blog.csdn.net/mn960mn/article/details/49560003

转载于:https://my.oschina.net/jamescasta/blog/713892

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值