Apache Tomcat Maven Plugin

groupId and Mojo name change

Since version 2.0-beta-1 tomcat mojos has been renamed to tomcat6 and tomcat7 with the same goals.

You must configure your pom to use this new groupId:

 
   

Or add the groupId in your settings.xml

 
   

Known limitations

Some goals are not yet available with the tomcat7 mojo. Those container goals are available with the tomcat6 mojo, you only need to update the manager url in your pom.

Use http://localhost:8080/manager/text rather than the default tomcat6 url.

 

Context Goals

Redeploying a WAR project

The goals required to redeploy a WAR project depend upon how it was deployed:

  • To redeploy a WAR project deployed by tomcat:deploy you can type:
     
           
  • To redeploy a WAR project deployed by tomcat:exploded you can type:
     
           
  • To redeploy a WAR project deployed by tomcat:inplace you can type:
     
           
  • To redeploy a context.xml file deployed by tomcat:deploy you can type:
     
           

    Note: Depending on the docBase specified in the context.xml you may also need to call war:exploded or war:inplace as above.

Undeploying a WAR project

To undeploy a WAR from Tomcat you can type:

 
     

Starting a WAR project

To start a WAR in Tomcat you can type:

 
     

Stopping a WAR project

To stop a WAR in Tomcat you can type:

 
     

Listing session statistics

To list the session statistics for a deployed WAR project you can type:

 
      
 

Container Goals

Listing deployed applications

To list all the currently deployed applications in Tomcat you can type:

 
    

Listing server information

To list information about the Tomcat version, OS, and JVM properties you can type:

 
    

Listing JNDI resources

To list all the JNDI resources available within Tomcat you can type:

 
    

Alternatively, to list only JNDI resources of a specific type you can type:

 
    

Listing security roles

To list the available security roles available within Tomcat you can type:

 
     
 

Build an Executable War/Jar

Starting with Version 2.0 of the plugin you can build an executable war/jar with an embedded Apache Tomcat7.

This is only supported with the tomcat7 plugin.

Note Your project must have a packaging value of pom or war.

Artifact to add to your war module:

 
   

Artifact to add to your pom module:

 
   

Generated executable jar/war

With the above configuration you can execute the generated jar due to its embedded Tomcat container

 
   

Help output

 
   

 

Run Mojo: run your Maven war project quickly!

When developing a war project, you usually build your war and deploy it to an installed Tomcat instance. This is time and resources consuming and also requires a local Tomcat instance.

The run mojo gives you the opportunity to avoid those efforts by simply running your war inside an embedded Tomcat instance in your Maven build.

NOTE If you have a multi module Maven project and use Maven3, you don't need to install all modules before using the run goal, just use tomcat6/7:run from the root module and the plugin will auto detect the build output directory from various modules and replace dependencies with those directories in the webapp classloader.

Running an embedded Tomcat

Configure your pom with the plugin version (for other mojo parameters see each mojo's documentation).

And use: mvn tomcat6/7:run

 
   

Maven project structure

 
   

With the structure given above, from the top level directory use mvn tomcat6/7:run -pl :my-webapp -am.

Use it with selenium mojo

You can use this mojo to start your application in a Tomcat instance and run your selenium test against this instance.

The following configuration will start an embedded Tomcat in the pre-integration-test and stop it in the post-integration-test.

 
   

转载于:https://www.cnblogs.com/gcg0036/p/4417895.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值